aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--simplify.c20
-rw-r--r--validation/optim/set-uimm0.c6
2 files changed, 25 insertions, 1 deletions
diff --git a/simplify.c b/simplify.c
index 4441b27c..96cd73a0 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1176,11 +1176,31 @@ static int simplify_constant_rightside(struct instruction *insn)
case OP_SET_B:
if (!value) { // (x < 0) --> 0
return replace_with_pseudo(insn, value_pseudo(0));
+ } else if (value == 1) { // (x < 1) --> (x == 0)
+ insn->src2 = value_pseudo(0);
+ insn->opcode = OP_SET_EQ;
+ return REPEAT_CSE;
}
break;
case OP_SET_AE:
if (!value) { // (x >= 0) --> 1
return replace_with_pseudo(insn, value_pseudo(1));
+ } else if (value == 1) { // (x >= 1) --> (x != 0)
+ insn->src2 = value_pseudo(0);
+ insn->opcode = OP_SET_NE;
+ return REPEAT_CSE;
+ }
+ break;
+ case OP_SET_BE:
+ if (!value) { // (x <= 0) --> (x == 0)
+ insn->opcode = OP_SET_EQ;
+ return REPEAT_CSE;
+ }
+ break;
+ case OP_SET_A:
+ if (!value) { // (x > 0) --> (x != 0)
+ insn->opcode = OP_SET_NE;
+ return REPEAT_CSE;
}
break;
}
diff --git a/validation/optim/set-uimm0.c b/validation/optim/set-uimm0.c
index 1f62358f..ded8fc82 100644
--- a/validation/optim/set-uimm0.c
+++ b/validation/optim/set-uimm0.c
@@ -1,10 +1,14 @@
static _Bool setlt0(unsigned int a) { return (a < 0u) == 0; }
static _Bool setge0(unsigned int a) { return (a >= 0u) == 1; }
+static _Bool setle0(unsigned int a) { return (a <= 0u) == (a == 0); }
+static _Bool setgt0(unsigned int a) { return (a > 0u) == (a != 0); }
+static _Bool setlt1(unsigned int a) { return (a < 1u) == (a == 0); }
+static _Bool setge1(unsigned int a) { return (a >= 1u) == (a != 0); }
/*
* check-name: set-uimm0
* check-command: test-linearize $file
*
* check-output-ignore
- * check-output-pattern(2): ret\\.1 *\\$1
+ * check-output-pattern(6): ret\\.1 *\\$1
*/