Skip to content

Commit 1ea7975

Browse files
WIP trying to repro bug
1 parent 2982f5c commit 1ea7975

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,5 +719,32 @@ func foo(len: Int,val: Int,x: Int,y: Int)->[Int]
719719
L1:
720720
""", result);
721721
}
722+
@Test
723+
public void testSSA19()
724+
{
725+
String src = """
726+
func bug(N: Int)
727+
{
728+
// The main Sieve array
729+
//var ary = new [Int]{len=N,value=0}
730+
var p=2
731+
// Find primes while p^2 < N
732+
while( p*p < N ) {
733+
// skip marked non-primes
734+
//while( ary[p] ) {
735+
while (p) {
736+
p = p + 1
737+
}
738+
p = p + 1
739+
}
722740
741+
// Now just collect the remaining primes, no more marking
742+
while ( p < N ) {
743+
p = p + 1
744+
}
745+
}
746+
""";
747+
String result = compileSrc(src);
748+
System.out.println(result);
749+
}
723750
}

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,4 +3059,33 @@ func foo(len: Int, val: Int, x: Int, y: Int)->[Int] {
30593059
L1:
30603060
""", result);
30613061
}
3062+
3063+
@Test
3064+
public void testSSA19()
3065+
{
3066+
String src = """
3067+
func bug(N: Int)
3068+
{
3069+
// The main Sieve array
3070+
//var ary = new [Int]{len=N,value=0}
3071+
var p=2
3072+
// Find primes while p^2 < N
3073+
while( p*p < N ) {
3074+
// skip marked non-primes
3075+
//while( ary[p] ) {
3076+
while (p) {
3077+
p = p + 1
3078+
}
3079+
p = p + 1
3080+
}
3081+
3082+
// Now just collect the remaining primes, no more marking
3083+
while ( p < N ) {
3084+
p = p + 1
3085+
}
3086+
}
3087+
""";
3088+
String result = compileSrc(src);
3089+
System.out.println(result);
3090+
}
30623091
}

0 commit comments

Comments
 (0)