Fix a bug in SSA construction.
If a join block does not have an incoming value for a local
from a predecessor block, we should not create a phi. The
verifier has made sure the local is updated before any
following reads after this block.
Change-Id: Id2785efc73c9fb3224826fff2f4b4ad215905ff4
diff --git a/test/402-optimizing-control-flow/src/Main.java b/test/402-optimizing-control-flow/src/Main.java
index 3339ef4..c9c24dd 100644
--- a/test/402-optimizing-control-flow/src/Main.java
+++ b/test/402-optimizing-control-flow/src/Main.java
@@ -40,6 +40,9 @@
result = $opt$testForLoop(42);
expectEquals(44, result);
+
+ result = $opt$testIfWithLocal(5);
+ expectEquals(7, result);
}
static int $opt$testIfEq1(int a) {
@@ -73,4 +76,14 @@
for (; a != 44; a++) {}
return a;
}
+
+ static int $opt$testIfWithLocal(int a) {
+ if (a == 5) {
+ int f = 2;
+ a += f;
+ }
+ // The SSA builder should not create a phi for f.
+
+ return a;
+ }
}