aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--simplify.c15
-rw-r--r--validation/optim/cmpe-or0.c1
2 files changed, 15 insertions, 1 deletions
diff --git a/simplify.c b/simplify.c
index b46e08c3..865fadfb 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 bef23161..2e89d611 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