< 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

        

@@ -24,17 +24,16 @@
 
 import org.graalvm.compiler.core.test.GraalCompilerTest;
 import org.graalvm.compiler.graph.iterators.NodeIterable;
 import org.graalvm.compiler.nodes.LoopBeginNode;
 import org.graalvm.compiler.nodes.StructuredGraph;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class LoopPartialUnrollTest extends GraalCompilerTest {
 
     @Override
-    protected boolean checkLowTierGraph(StructuredGraph graph) {
+    protected boolean checkMidTierGraph(StructuredGraph graph) {
         NodeIterable<LoopBeginNode> loops = graph.getNodes().filter(LoopBeginNode.class);
         for (LoopBeginNode loop : loops) {
             if (loop.isMainLoop()) {
                 return true;
             }

@@ -43,11 +42,11 @@
     }
 
     public static long testMultiplySnippet(int arg) {
         long r = 1;
         for (int i = 0; branchProbability(0.99, i < arg); i++) {
-            r *= i;
+            r += r * i;
         }
         return r;
     }
 
     @Test

@@ -57,11 +56,28 @@
 
     public static int testNestedSumSnippet(int d) {
         int c = 0;
         for (int i = 0; i < d; i++) {
             for (int j = 0; branchProbability(0.99, j < i); j++) {
-                c += j & 0x3;
+                c += c + j & 0x3;
+            }
+        }
+        return c;
+    }
+
+    @Test
+    public void testNestedSumBy2() {
+        for (int i = 0; i < 1000; i++) {
+            test("testNestedSumBy2Snippet", i);
+        }
+    }
+
+    public static int testNestedSumBy2Snippet(int d) {
+        int c = 0;
+        for (int i = 0; i < d; i++) {
+            for (int j = 0; branchProbability(0.99, j < i); j += 2) {
+                c += c + j & 0x3;
             }
         }
         return c;
     }
 

@@ -73,33 +89,50 @@
     }
 
     public static int testSumDownSnippet(int d) {
         int c = 0;
         for (int j = d; branchProbability(0.99, j > -4); j--) {
-            c += j & 0x3;
+            c += c + j & 0x3;
         }
         return c;
     }
 
     @Test
     public void testSumDown() {
         test("testSumDownSnippet", 1);
-        for (int i = 0; i < 8; i++) {
+        for (int i = 0; i < 160; i++) {
             test("testSumDownSnippet", i);
         }
     }
 
-    @Ignore("Phis which reference the backedge value of other Phis aren't handled properly")
+    public static int testSumDownBy2Snippet(int d) {
+        int c = 0;
+        for (int j = d; branchProbability(0.99, j > -4); j -= 2) {
+            c += c + j & 0x3;
+        }
+        return c;
+    }
+
+    @Test
+    public void testSumDownBy2() {
+        test("testSumDownBy2Snippet", 1);
+        for (int i = 0; i < 160; i++) {
+            test("testSumDownBy2Snippet", i);
+        }
+    }
+
     @Test
     public void testLoopCarried() {
         test("testLoopCarriedSnippet", 1, 2);
+        test("testLoopCarriedSnippet", 0, 4);
+        test("testLoopCarriedSnippet", 4, 0);
     }
 
     public static int testLoopCarriedSnippet(int a, int b) {
         int c = a;
         int d = b;
-        for (int j = 0; j < a; j++) {
+        for (int j = 0; branchProbability(0.99, j < a); j++) {
             d = c;
             c += 1;
         }
         return c + d;
     }

@@ -134,6 +167,18 @@
         test("testComplexSnippet", 10);
         test("testComplexSnippet", 100);
         test("testComplexSnippet", 1000);
     }
 
+    public static long testSignExtensionSnippet(long arg) {
+        long r = 1;
+        for (int i = 0; branchProbability(0.99, i < arg); i++) {
+            r *= i;
+        }
+        return r;
+    }
+
+    @Test
+    public void testSignExtension() {
+        test("testSignExtensionSnippet", 9L);
+    }
 }
< prev index next >