diff mbox series

[4/9] simplify (x & M) cmpu C

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

Patch

diff --git a/simplify.c b/simplify.c
index 90b0c5ba0127..ee29c9619bdc 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1281,6 +1281,22 @@  static int simplify_compare_constant(struct instruction *insn, long long value)
 			if (value >= (long long)bits)
 				return replace_with_value(insn, 0);
 			break;
+		case OP_SET_B:
+			if (value > bits)
+				return replace_with_value(insn, 1);
+			break;
+		case OP_SET_BE:
+			if (value >= bits)
+				return replace_with_value(insn, 1);
+			break;
+		case OP_SET_AE:
+			if (value > bits)
+				return replace_with_value(insn, 0);
+			break;
+		case OP_SET_A:
+			if (value >= bits)
+				return replace_with_value(insn, 0);
+			break;
 		}
 		break;
 	case OP_SEXT:				// sext(x) cmp C --> x cmp trunc(C)
diff --git a/validation/optim/cmpu-and0.c b/validation/optim/cmpu-and0.c
index 253212941779..927b9fb65f52 100644
--- a/validation/optim/cmpu-and0.c
+++ b/validation/optim/cmpu-and0.c
@@ -11,7 +11,6 @@  int cmps_and_gtu_eq(int a) { return ((a & MASK) >  (MASK + 0)) + 1; }
 /*
  * check-name: cmpu-and0
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-returns: 1