Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/test/compiler/5091921/Test6559156.java
32285 views
/*1* Copyright (c) 2011, 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*22*/2324/**25* @test26* @bug 655915627* @summary Server compiler generates bad code for "<= Integer.MAX_VALUE" expression28*29* @run main Test655915630*/3132public class Test6559156 {3334static final int N_TESTS = 1000000;3536public static void main(String[] args) throws Exception {3738/*39* If MAX_VALUE is changed to MAX_VALUE - 1 below, the test passes40* because (apparently) bad code is only generated when comparing41* <= MAX_VALUE in the doTest method.42*/43Test6559156 test = new Test6559156();44for (int i = 0; i < N_TESTS; i += 1) {45test.doTest1(10, Integer.MAX_VALUE, i);46test.doTest2(10, Integer.MAX_VALUE, i);47}48System.out.println("No failure");49}5051void doTest1(int expected, int max, int i) {52int counted;53for (counted = 0;54(counted <= max) && (counted < expected);55counted += 1) {56}57if (counted != expected) {58throw new RuntimeException("Failed test1 iteration=" + i +59" max=" + max +60" counted=" + counted +61" expected=" + expected);62}63}6465void doTest2(int expected, int max, int i) {66int counted;67for (counted = 0;68// change test sequence.69(counted < expected) && (counted <= max);70counted += 1) {71}72if (counted != expected) {73throw new RuntimeException("Failed test1 iteration=" + i +74" max=" + max +75" counted=" + counted +76" expected=" + expected);77}78}79}80818283