Path: blob/master/test/hotspot/jtreg/compiler/loopstripmining/CheckLoopStripMining.java
41152 views
/*1* Copyright (c) 2019 SAP SE. 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 8220374 824149226* @summary C2: LoopStripMining doesn't strip as expected27* @requires vm.compiler2.enabled28*29* @library /test/lib30* @run driver compiler.loopstripmining.CheckLoopStripMining31*/3233package compiler.loopstripmining;3435import jdk.test.lib.Utils;36import jdk.test.lib.process.ProcessTools;3738public class CheckLoopStripMining {39public static void main(String args[]) throws Exception {40ProcessTools.executeTestJvm("-XX:+UnlockDiagnosticVMOptions",41// to prevent biased locking handshakes from changing the timing of this test42"-XX:-UseBiasedLocking",43"-XX:+SafepointTimeout",44"-XX:+SafepointALot",45"-XX:+AbortVMOnSafepointTimeout",46"-XX:SafepointTimeoutDelay=" + Utils.adjustTimeout(300),47"-XX:GuaranteedSafepointInterval=" + Utils.adjustTimeout(300),48"-XX:-TieredCompilation",49"-XX:+UseCountedLoopSafepoints",50"-XX:LoopStripMiningIter=1000",51"-XX:LoopUnrollLimit=0",52"-XX:CompileCommand=compileonly,compiler.loopstripmining.CheckLoopStripMining$Test1::test_loop",53"-Xcomp",54Test1.class.getName())55.shouldHaveExitValue(0)56.stdoutShouldContain("sum: 715827882");5758ProcessTools.executeTestJvm("-XX:+UnlockDiagnosticVMOptions",59// to prevent biased locking handshakes from changing the timing of this test60"-XX:-UseBiasedLocking",61"-XX:+SafepointTimeout",62"-XX:+SafepointALot",63"-XX:+AbortVMOnSafepointTimeout",64"-XX:SafepointTimeoutDelay=" + Utils.adjustTimeout(300),65"-XX:GuaranteedSafepointInterval=" + Utils.adjustTimeout(300),66"-XX:-TieredCompilation",67"-XX:+UseCountedLoopSafepoints",68"-XX:LoopStripMiningIter=1000",69"-XX:LoopUnrollLimit=0",70"-XX:-BackgroundCompilation",71Test2.class.getName())72.shouldHaveExitValue(0);73}7475public static class Test1 {76public static int test_loop(int x) {77int sum = 0;78if (x != 0) {79for (int y = 1; y < Integer.MAX_VALUE; ++y) {80if (y % x == 0) ++sum;81}82}83return sum;84}8586public static void main(String args[]) {87int sum = test_loop(3);88System.out.println("sum: " + sum);89}90}9192public static class Test2 {93public static int test_loop(int start, int stop) {94int sum = 0;95for (int x = start; x < stop; x++) {96sum += x;97}98return sum;99}100101public static void main(String args[]) {102for (int i = 0; i < 20_000; i++) {103test_loop(0, 1);104}105test_loop(Integer.MIN_VALUE, 0);106test_loop(-1, Integer.MAX_VALUE);107test_loop(Integer.MIN_VALUE, Integer.MAX_VALUE);108}109}110}111112113