< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.loop.test/src/org/graalvm/compiler/loop/test/LoopPartialUnrollTest.java
Print this page
rev 52509 : [mq]: graal
@@ -81,19 +81,19 @@
}
@Ignore("equality limits aren't working properly")
@Test
public void testSumWithEqualityLimit() {
- for (int i = 0; i < 128; i++) {
+ for (int i = -1; i < 128; i++) {
int[] data = new int[i];
test("sumWithEqualityLimit", data);
}
}
@Test
public void testLoopCarried() {
- for (int i = 0; i < 64; i++) {
+ for (int i = -1; i < 64; i++) {
test("testLoopCarriedSnippet", i);
}
}
@Test
@@ -101,11 +101,11 @@
testDuplicateBody("testLoopCarriedReference", "testLoopCarriedSnippet");
}
static volatile int volatileInt = 3;
- public int testLoopCarriedSnippet(int iterations) {
+ public static int testLoopCarriedSnippet(int iterations) {
int a = 0;
int b = 0;
int c = 0;
for (int i = 0; branchProbability(0.99, i < iterations); i++) {
@@ -117,11 +117,11 @@
}
return c;
}
- public int testLoopCarriedReference(int iterations) {
+ public static int testLoopCarriedReference(int iterations) {
int a = 0;
int b = 0;
int c = 0;
for (int i = 0; branchProbability(0.99, i < iterations); i += 2) {
@@ -138,10 +138,41 @@
}
return c;
}
+ @Test
+ public void testLoopCarried2() {
+ for (int i = -1; i < 64; i++) {
+ for (int j = -1; j < 64; j++) {
+ test("testLoopCarried2Snippet", i, j);
+ }
+ }
+ test("testLoopCarried2Snippet", Integer.MAX_VALUE - 32, Integer.MAX_VALUE);
+ test("testLoopCarried2Snippet", Integer.MAX_VALUE - 4, Integer.MAX_VALUE);
+ test("testLoopCarried2Snippet", Integer.MAX_VALUE, 0);
+ test("testLoopCarried2Snippet", Integer.MIN_VALUE, Integer.MIN_VALUE + 32);
+ test("testLoopCarried2Snippet", Integer.MIN_VALUE, Integer.MIN_VALUE + 4);
+ test("testLoopCarried2Snippet", 0, Integer.MIN_VALUE);
+ }
+
+ public static int testLoopCarried2Snippet(int start, int end) {
+ int a = 0;
+ int b = 0;
+ int c = 0;
+
+ for (int i = start; branchProbability(0.99, i < end); i++) {
+ int t1 = volatileInt;
+ int t2 = a + b;
+ c = b;
+ b = a;
+ a = t1 + t2;
+ }
+
+ return c;
+ }
+
public static long init = Runtime.getRuntime().totalMemory();
private int x;
private int z;
public int[] testComplexSnippet(int d) {
@@ -162,11 +193,11 @@
return new int[]{x, y, z};
}
@Test
public void testComplex() {
- for (int i = 0; i < 10; i++) {
+ for (int i = -1; i < 10; i++) {
test("testComplexSnippet", i);
}
test("testComplexSnippet", 10);
test("testComplexSnippet", 100);
test("testComplexSnippet", 1000);
@@ -238,11 +269,11 @@
if (partialUnroll) {
LoopsData dataCounted = new LoopsData(graph);
dataCounted.detectedCountedLoops();
for (LoopEx loop : dataCounted.countedLoops()) {
LoopFragmentInside newSegment = loop.inside().duplicate();
- newSegment.insertWithinAfter(loop, false);
+ newSegment.insertWithinAfter(loop, null);
}
canonicalizer.apply(graph, getDefaultMidTierContext());
}
new DeadCodeEliminationPhase().apply(graph);
canonicalizer.apply(graph, context);
< prev index next >