diff mbox series

[8/9] simplify (x | M) cmps C

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

Patch

diff --git a/simplify.c b/simplify.c
index 865fadfb590e..e721f9f860a0 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1324,6 +1324,20 @@  static int simplify_compare_constant(struct instruction *insn, long long value)
 			if ((value & bits) != bits)
 				return replace_with_value(insn, 1);
 			break;
+		case OP_SET_LE:
+			value = sign_extend(value, def->size);
+			if (bits & sign_bit(def->size)) {
+				if (value >= -1)
+					return replace_with_value(insn, 1);
+			}
+			break;
+		case OP_SET_GT:
+			value = sign_extend(value, def->size);
+			if (bits & sign_bit(def->size)) {
+				if (value >= -1)
+					return replace_with_value(insn, 0);
+			}
+			break;
 		}
 		break;
 	case OP_SEXT:				// sext(x) cmp C --> x cmp trunc(C)
diff --git a/validation/optim/cmps-or0.c b/validation/optim/cmps-or0.c
index 40a2092c58a4..70fcb024a846 100644
--- a/validation/optim/cmps-or0.c
+++ b/validation/optim/cmps-or0.c
@@ -15,7 +15,6 @@  int cmps_ior_gt_0(int a) { return ((a | MASK) >  0) EQ(0); }
 /*
  * check-name: cmps-or0
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-returns: 1