Path: blob/master/test/hotspot/jtreg/compiler/loopopts/TestDeadCountedLoop.java
64478 views
/*1* Copyright (c) 2021, 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 826739926* @summary C2: java/text/Normalizer/ConformanceTest.java test failed with assertion27*28* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation TestDeadCountedLoop29*30*/3132public class TestDeadCountedLoop {33public static void main(String[] args) {34for (int i = 0; i < 20_000; i++) {35test(true, new int[10], false, 0, 1);36test(false, new int[10], false, 0, 1);37}38}3940private static int test(boolean flag, int[] array2, boolean flag2, int start, int stop) {41if (array2 == null) {42}43int[] array;44if (flag) {45array = new int[1];46} else {47array = new int[2];48}49int len = array.length;50int v = 1;51for (int j = start; j < stop; j++) {52for (int i = 0; i < len; i++) {53if (i > 0) {54if (flag2) {55break;56}57v *= array2[i + j];58}59}60}6162return v;63}64}656667