aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-11-26 22:26:47 +0100
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-11-26 22:26:47 +0100
commitf50c482ebabe3572cdd8a97d8b51ca94e44aba3a (patch)
treea5c64e5ef06e55ebb6c2d848c0cd1e89f6e014d0
parent1abdabb5651d65a8f816bdc22487a11393514061 (diff)
parentfe9dbeb3d0ab6b12448e0eed96df1b8499d91c3c (diff)
downloadsparse-f50c482ebabe3572cdd8a97d8b51ca94e44aba3a.tar.gz
Merge branch 'fix-trivial-phi' into next
* fix trivial_phi() when the target is before the single value
-rw-r--r--simplify.c4
-rw-r--r--validation/optim/trivial-phi01.c20
2 files changed, 22 insertions, 2 deletions
diff --git a/simplify.c b/simplify.c
index de03d315..5238d33f 100644
--- a/simplify.c
+++ b/simplify.c
@@ -204,14 +204,14 @@ static pseudo_t trivial_phi(pseudo_t pseudo, struct instruction *insn, struct ps
src = def->phi_src; // bypass OP_PHISRC & get the real source
if (src == VOID)
continue;
+ if (src == target)
+ continue;
if (!pseudo) {
pseudo = src;
continue;
}
if (src == pseudo)
continue;
- if (src == target)
- continue;
if (DEF_OPCODE(def, src) == OP_PHI) {
if (pseudo_in_list(*list, src))
continue;
diff --git a/validation/optim/trivial-phi01.c b/validation/optim/trivial-phi01.c
new file mode 100644
index 00000000..40bd343b
--- /dev/null
+++ b/validation/optim/trivial-phi01.c
@@ -0,0 +1,20 @@
+void foo(int a)
+{
+ if (a) {
+ while (a) {
+ switch (0) {
+ default:
+ a = 0;
+ case 0:;
+ }
+ }
+ }
+}
+
+/*
+ * check-name: trivial-phi01
+ * check-command: test-linearize -Wno-decl $file
+ *
+ * check-output-ignore
+ * check-output-excludes: phi\\.
+ */