aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
-rw-r--r--simplify.c6
-rw-r--r--validation/optim/select-zero.c16
2 files changed, 22 insertions, 0 deletions
diff --git a/simplify.c b/simplify.c
index 0a320740..e5e555c1 100644
--- a/simplify.c
+++ b/simplify.c
@@ -1019,6 +1019,12 @@ static int simplify_select(struct instruction *insn)
return REPEAT_CSE;
}
}
+ if (cond == src2 && is_zero(src1)) {
+ kill_use(&insn->src1);
+ kill_use(&insn->src3);
+ replace_with_pseudo(insn, value_pseudo(0));
+ return REPEAT_CSE;
+ }
return 0;
}
diff --git a/validation/optim/select-zero.c b/validation/optim/select-zero.c
new file mode 100644
index 00000000..ed737bff
--- /dev/null
+++ b/validation/optim/select-zero.c
@@ -0,0 +1,16 @@
+static int sel0(int a)
+{
+ if (a)
+ return 0;
+ else
+ return a;
+}
+
+/*
+ * check-name: select-zero
+ * check-command: test-linearize $file
+ *
+ * check-output-ignore
+ * check-output-contains: ret.32 *\\$0
+ * check-output-excludes: select\\.
+ */