[PATCH 6/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                   | 8 ++++++++
 validation/optim/cmpe-and0.c | 1 -
 2 files changed, 8 insertions(+), 1 deletion(-)

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
-- 
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