Skip to content

Commit 87604c2

Browse files
#20 ssa transform useless phis
1 parent 52a83d8 commit 87604c2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

optvm/src/test/java/com/compilerprogramming/ezlang/compiler/TestSSATransform.java

+26
Original file line numberDiff line numberDiff line change
@@ -814,4 +814,30 @@ func foo(x: Int) {
814814
System.out.println(result);
815815
}
816816

817+
// http://users.csc.calpoly.edu/~akeen/courses/csc431/handouts/references/ssa_example.pdf
818+
@Test
819+
public void testSSAExample() {
820+
// TODO
821+
String src = """
822+
func foo(x: Int, y: Int)->Int {
823+
var sum: Int
824+
825+
if (x >= y)
826+
return 0
827+
828+
sum = 0;
829+
while (x < y) {
830+
if (x / 2 * 2 == x) {
831+
sum = sum + 1
832+
}
833+
x = x + 1
834+
}
835+
return sum
836+
}
837+
""";
838+
String result = compileSrc(src);
839+
System.out.println(result);
840+
841+
}
842+
817843
}

0 commit comments

Comments
 (0)