aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--simplify.c10
-rw-r--r--validation/optim/set-uimm0.c10
2 files changed, 20 insertions, 0 deletions
diff --git a/simplify.c b/simplify.c
index 6caf6cbc..4441b27c 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1173,6 +1173,16 @@ static int simplify_constant_rightside(struct instruction *insn)
case OP_SET_NE:
case OP_SET_EQ:
return simplify_seteq_setne(insn, value);
+ case OP_SET_B:
+ if (!value) { // (x < 0) --> 0
+ return replace_with_pseudo(insn, value_pseudo(0));
+ }
+ break;
+ case OP_SET_AE:
+ if (!value) { // (x >= 0) --> 1
+ return replace_with_pseudo(insn, value_pseudo(1));
+ }
+ break;
}
return 0;
}
diff --git a/validation/optim/set-uimm0.c b/validation/optim/set-uimm0.c
new file mode 100644
index 00000000..1f62358f
--- /dev/null
+++ b/validation/optim/set-uimm0.c
@@ -0,0 +1,10 @@
+static _Bool setlt0(unsigned int a) { return (a < 0u) == 0; }
+static _Bool setge0(unsigned int a) { return (a >= 0u) == 1; }
+
+/*
+ * check-name: set-uimm0
+ * check-command: test-linearize $file
+ *
+ * check-output-ignore
+ * check-output-pattern(2): ret\\.1 *\\$1
+ */