Path: blob/master/test/hotspot/jtreg/compiler/loopopts/CountedLoopPeelingProfilePredicates.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 820551526* @summary CountedLoopEndNode from peeled loop body is not candidate for profile loop predication27*28* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement CountedLoopPeelingProfilePredicates29*30*/3132import java.util.Arrays;3334public class CountedLoopPeelingProfilePredicates {35public static void main(String[] args) {36int stop = 2;37boolean[] flags1 = new boolean[stop];38flags1[stop-1] = true;39boolean[] flags2 = new boolean[stop];40flags2[0] = true;41boolean[] flags3 = new boolean[100];42Arrays.fill(flags3, true);43flags3[0] = false;4445for (int i = 0; i < 20_000; i++) {46test_helper(stop, flags1, false);47test_helper(stop, flags2, false);48test_helper(stop, flags2, false);49}50for (int i = 0; i < 20_000; i++) {51test(stop, flags1, false, flags3, 1);52test(stop, flags2, false, flags3, 1);53test(stop, flags2, false, flags3, 1);54}55}56575859private static void test(int stop, boolean[] flags1, boolean flag2, boolean[] flags3, int inc) {60for (int j = 0; j < 100; j+=inc) {61if (flags3[j]) {62test_helper(stop, flags1, flag2);63}64}65}6667private static void test_helper(int stop, boolean[] flags1, boolean flag2) {68for (int i = 0; i < stop; i++) {69if (flags1[i]) {70return;71}72if (flag2) {73}74}75}76}777879