Path: blob/master/test/hotspot/jtreg/compiler/loopstripmining/LimitSharedwithOutOfLoopTest.java
41149 views
/*1* Copyright (c) 2018, Red Hat, Inc. 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 819359726* @summary limit test is shared with out of loop if27*28* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-BackgroundCompilation -XX:LoopUnrollLimit=0 -XX:+UseCountedLoopSafepoints -XX:LoopStripMiningIter=1000 LimitSharedwithOutOfLoopTest29*30*/3132public class LimitSharedwithOutOfLoopTest {33public static void main(String[] args) {34boolean[] array1 = new boolean[2001];35boolean[] array2 = new boolean[2001];36boolean[] array3 = new boolean[2001];37array2[1000] = true;38array3[2000] = true;39for (int i = 0; i < 20_000; i++) {40if (test(2000, array1)) {41throw new RuntimeException("bad return");42}43if (!test(2000, array2)) {44throw new RuntimeException("bad return");45}46if (test(2000, array3)) {47throw new RuntimeException("bad return");48}49}50}5152static volatile boolean barrier;5354private static boolean test(int limit, boolean[] array) {55for (int i = 0; i < limit;) {56i++;57if (array[i]) {58// Same test as end of loop test. When loop is strip59// mined, this must not become the end of inner loop60// test.61if (i < limit) {62return true;63}64return false;65}66barrier = true;67}68return false;69}70}717273