diff mbox series

[5/9] simplify (x & M) cmps 0

Message ID 20210310214950.84192-6-luc.vanoostenryck@gmail.com (mailing list archive)
State Mainlined, archived
Headers show
Series simplify CMP(AND(x,M), C) and CMP(OR(x,M), C) | expand

Commit Message

Luc Van Oostenryck March 10, 2021, 9:49 p.m. UTC
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 simplify.c                    | 4 ++++
 validation/optim/cmps0-and0.c | 1 -
 2 files changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/simplify.c b/simplify.c
index ee29c9619bdc..6c11018ea3bf 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1271,6 +1271,8 @@  static int simplify_compare_constant(struct instruction *insn, long long value)
 				return replace_with_value(insn, 0);
 			if (value >= (long long)bits)
 				return replace_with_value(insn, 1);
+			if (value == 0)
+				return replace_opcode(insn, OP_SET_EQ);
 			break;
 		case OP_SET_GT:
 			value = sign_extend(value, def->size);
@@ -1280,6 +1282,8 @@  static int simplify_compare_constant(struct instruction *insn, long long value)
 				return replace_with_value(insn, 1);
 			if (value >= (long long)bits)
 				return replace_with_value(insn, 0);
+			if (value == 0)
+				return replace_opcode(insn, OP_SET_NE);
 			break;
 		case OP_SET_B:
 			if (value > bits)
diff --git a/validation/optim/cmps0-and0.c b/validation/optim/cmps0-and0.c
index 819a1dc2a793..8316916abc8c 100644
--- a/validation/optim/cmps0-and0.c
+++ b/validation/optim/cmps0-and0.c
@@ -6,7 +6,6 @@  int cmps_and_sgt0(int a) { return ((a & M) >  0) == ((a & M) != 0); }
 /*
  * check-name: cmps0-and
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-returns: 1