< prev index next >

test/hotspot/jtreg/compiler/loopopts/TestMoveStoresOutOfLoops.java

Print this page

        

*** 21,31 **** * questions. */ /** * @test ! * @bug 8080289 * @summary Move stores out of loops if possible * * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation * -XX:CompileCommand=dontinline,compiler.loopopts.TestMoveStoresOutOfLoops::test* * compiler.loopopts.TestMoveStoresOutOfLoops --- 21,31 ---- * questions. */ /** * @test ! * @bug 8080289 8189067 * @summary Move stores out of loops if possible * * @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation * -XX:CompileCommand=dontinline,compiler.loopopts.TestMoveStoresOutOfLoops::test* * compiler.loopopts.TestMoveStoresOutOfLoops
*** 41,50 **** --- 41,51 ---- public class TestMoveStoresOutOfLoops { private static long[] array = new long[10]; private static long[] array2 = new long[10]; private static boolean[] array3 = new boolean[1000]; + private static int[] array4 = new int[1000]; private static byte[] byte_array = new byte[10]; // Array store should be moved out of the loop, value stored // should be 999, the loop should be eliminated static void test_after_1(int idx) {
*** 106,115 **** --- 107,125 ---- return; } } } + // Array store can be moved out of the inner loop + static void test_after_7(int idx) { + for (int i = 0; i < 1000; i++) { + for (int j = 0; j <= 42; j++) { + array4[i] = j; + } + } + } + // Optimize out redundant stores static void test_stores_1(int ignored) { array[0] = 0; array[1] = 1; array[2] = 2;
*** 283,302 **** --- 293,324 ---- } } return success; } + static boolean array_check5(String name) { + boolean success = true; + for (int i = 0; i < 1000; i++) { + if (array4[i] != 42) { + success = false; + System.out.println(name + " failed: array[" + i + "] = " + array4[i]); + } + } + return success; + } + static public void main(String[] args) throws Exception { TestMoveStoresOutOfLoops test = new TestMoveStoresOutOfLoops(); test.doTest("test_after_1", TestMoveStoresOutOfLoops::array_init, TestMoveStoresOutOfLoops::array_check); test.doTest("test_after_2", TestMoveStoresOutOfLoops::array_init, TestMoveStoresOutOfLoops::array_check); test.doTest("test_after_3", TestMoveStoresOutOfLoops::array_init, TestMoveStoresOutOfLoops::array_check); test.doTest("test_after_4", TestMoveStoresOutOfLoops::array_init, TestMoveStoresOutOfLoops::array_check); test.doTest("test_after_5", TestMoveStoresOutOfLoops::array_init2, TestMoveStoresOutOfLoops::array_check2); test.doTest("test_after_6", TestMoveStoresOutOfLoops::array_init, TestMoveStoresOutOfLoops::array_check); array3[999] = true; test.doTest("test_after_6", TestMoveStoresOutOfLoops::array_init, TestMoveStoresOutOfLoops::array_check); + test.doTest("test_after_7", TestMoveStoresOutOfLoops::array_init, TestMoveStoresOutOfLoops::array_check5); test.doTest("test_stores_1", TestMoveStoresOutOfLoops::array_init3, TestMoveStoresOutOfLoops::array_check3); test.doTest("test_stores_2", TestMoveStoresOutOfLoops::array_init3, TestMoveStoresOutOfLoops::array_check3); test.doTest("test_stores_3", TestMoveStoresOutOfLoops::array_init4, TestMoveStoresOutOfLoops::array_check4);
< prev index next >