[PATCH 7/9] simplify (x | M) {==,!=} C

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 simplify.c                  | 15 +++++++++++++++
 validation/optim/cmpe-or0.c |  1 -
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/simplify.c b/simplify.c
index b46e08c3b79a..865fadfb590e 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1311,6 +1311,21 @@ static int simplify_compare_constant(struct instruction *insn, long long value)
 			break;
 		}
 		break;
+	case OP_OR:
+		if (!constant(def->src2))
+			break;
+		bits = def->src2->value;
+		switch (insn->opcode) {
+		case OP_SET_EQ:
+			if ((value & bits) != bits)
+				return replace_with_value(insn, 0);
+			break;
+		case OP_SET_NE:
+			if ((value & bits) != bits)
+				return replace_with_value(insn, 1);
+			break;
+		}
+		break;
 	case OP_SEXT:				// sext(x) cmp C --> x cmp trunc(C)
 		osize = def->orig_type->bit_size;
 		if (is_signed_constant(value, osize, size)) {
diff --git a/validation/optim/cmpe-or0.c b/validation/optim/cmpe-or0.c
index bef2316120f7..2e89d611117d 100644
--- a/validation/optim/cmpe-or0.c
+++ b/validation/optim/cmpe-or0.c
@@ -4,7 +4,6 @@ int cmp_ne(int a) { return ((a | 1) == 0) + 1; }
 /*
  * check-name: cmpe-or0
  * check-command: test-linearize -Wno-decl $file
- * check-known-to-fail
  *
  * check-output-ignore
  * check-output-returns: 1
-- 
2.30.0




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux