Path: blob/master/test/hotspot/jtreg/compiler/loopopts/TestLoopLimitNodeElimination.java
41149 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 826037026* @summary C2: LoopLimit node is not eliminated27*28* @run main/othervm29* -Xcomp30* -XX:CompileOnly=compiler/loopopts/TestLoopLimitNodeElimination31* compiler.loopopts.TestLoopLimitNodeElimination32*/3334package compiler.loopopts;3536// the test code is derived from a randomly generated test37public class TestLoopLimitNodeElimination {38private static class MyException extends RuntimeException { }39private static final int ITERATIONS = 100000;40private static final int SIZE = 400;4142private static int counter = 0;4344int[] array1 = new int[SIZE];4546void test() {47int[] array2 = new int[SIZE];48array1[2] = 0;49array1 = array1;50for (long i = 301; i > 2; i -= 2) {51int j = 1;52do {53for (int k = (int) i; k < 1; k++) { }54} while (++j < 4);55}5657counter++;58if (counter == ITERATIONS) {59throw new MyException();60}61}6263public static void main(String[] args) {64try {65var test = new TestLoopLimitNodeElimination();66while (true) {67test.test();68}69} catch (MyException e) {70// expected71}72}73}74757677