Path: blob/master/test/hotspot/jtreg/compiler/loopopts/TestDepBetweenLoopAndPredicate.java
64478 views
/*1* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24* @test25* @bug 827752926* @summary RangeCheck should not be moved out of a loop if a node on the data input chain for the bool is dependent27* on the projection into the loop (after the predicates).28* @run main/othervm -Xbatch -XX:CompileCommand=compileonly,compiler.loopopts.TestDepBetweenLoopAndPredicate::test*29* compiler.loopopts.TestDepBetweenLoopAndPredicate30*/3132package compiler.loopopts;3334public class TestDepBetweenLoopAndPredicate {35static int x, y, z;36static boolean flag;37static int[] iArrFld = new int[25];38static int[] iArrFld2 = new int[5];39static int limit = 5;4041public static void main(String[] args) {42for (int i = 0; i < 10000; i++) {43flag = !flag;44test();45}4647for (int i = 0; i < 5000; i++) {48flag = !flag;49test2();50test3();51test4();52test5();53}54}5556public static void test() {57int[] iArr = new int[20];58System.arraycopy(iArrFld, x, iArr, y, 18);5960if (flag) {61return;62}6364for (int i = 0; i < limit; i++) {65iArr[19]++;66}67}6869public static void test2() {70for (int i = 0; i < limit; i++) {71int[] iArr = new int[20];72System.arraycopy(iArrFld, x, iArr, y, 18);7374if (flag) {75return;76}7778for (int j = i; j < limit; j++) {79x = iArrFld[iArr[19]]; // No new offset node created80iArr[19]++;81}82}83}8485public static void test3() {86for (int i = 0; i < limit; i++) {87int[] iArr = new int[20];88System.arraycopy(iArrFld, x, iArr, y, 18);8990if (flag) {91return;92}9394for (int j = i + 1; j < limit; j++) {95x = iArrFld[iArr[19]]; // New offset node created96iArr[19]++;97}98}99}100101public static void test4() {102for (int i = 0; i < limit; i++) {103int[] iArr = new int[20];104System.arraycopy(iArrFld, x, iArr, y, 18);105106if (flag) {107return;108}109110for (int j = i + 1 + z; j < limit; j++) {111x = iArrFld[iArr[19]]; // New offset node created112iArr[19]++;113}114}115}116117public static void test5() {118for (int i = 0; i < limit; i++) {119int[] iArr = new int[20];120System.arraycopy(iArrFld, x, iArr, y, 18);121122if (flag) {123return;124}125126for (int j = i + 1 + z; j < limit; j++) {127x = iArrFld[iArr[19]]; // New offset node created128iArr[19]++;129y += iArrFld2[3]; // Range check removed because not dependent on projection into the loop130}131}132}133}134135136