diff mbox series

[6/9] simplify (x & M) {==,!=} C

Message ID 20210310214950.84192-7-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                   | 8 ++++++++
 validation/optim/cmpe-and0.c | 1 -
 2 files changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/simplify.c b/simplify.c
index 6c11018ea3bf..b46e08c3b79a 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1263,6 +1263,14 @@  static int simplify_compare_constant(struct instruction *insn, long long value)
 			break;
 		bits = def->src2->value;
 		switch (insn->opcode) {
+		case OP_SET_EQ:
+			if ((value & bits) != value)
+				return replace_with_value(insn, 0);
+			break;
+		case OP_SET_NE:
+			if ((value & bits) != value)
+				return replace_with_value(insn, 1);
+			break;
 		case OP_SET_LE:
 			value = sign_extend(value, def->size);
 			if (bits & sign_bit(def->size))
diff --git a/validation/optim/cmpe-and0.c b/validation/optim/cmpe-and0.c
index 7db608365568..75af77528f61 100644
--- a/validation/optim/cmpe-and0.c
+++ b/validation/optim/cmpe-and0.c
@@ -4,7 +4,6 @@  int cmpe_and_ne(int a) { return ((a & 0xff00) != 0xff01) + 0; }
 /*
  * check-name: cmpe-and0
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-returns: 1