Path: blob/master/test/hotspot/jtreg/compiler/loopstripmining/TestConservativeAntiDep.java
41149 views
/*1* Copyright (c) 2019, 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 823155026* @summary C2: ShouldNotReachHere() in verify_strip_mined_scheduling27*28* @run main/othervm -XX:-BackgroundCompilation -XX:LoopMaxUnroll=0 TestConservativeAntiDep29*30*/3132import java.lang.reflect.Array;33import java.util.Arrays;3435public class TestConservativeAntiDep {36private static long longField;3738public static void main(String[] args) throws InstantiationException, IllegalAccessException {39for (int i = 0; i < 20_000; i++) {40test1(A.class);41test2(B.class);42}43}4445private static int test1(Class klass) {46Object[] in = (Object[])Array.newInstance(klass, 100);4748Object[] o = in;49int v = 1;50// CountedLoop has control dependent CastPP51for (int i = 0; i < 100 ; i++) {52longField = i; // sunk in outer strip mined loop53o = (A[]) o;54v *= 2;55}5657// LoadRange cannot float higher than CountedLoop (because of58// CastPP) and is found anti-dependent with long store so59// scheduled in outer strip mined loop60return v + o.length;61}6263private static int test2(Class klass) throws IllegalAccessException, InstantiationException {64A in = (A)klass.newInstance();6566A o = in;67int v = 1;68// CountedLoop has control dependent CastPP69for (int i = 0; i < 100 ; i++) {70longField = i; // sunk in outer strip mined loop71o = (B) o;72v *= 2;73}7475// Load cannot float higher than CountedLoop (because of76// CastPP) and is found anti-dependent with long store so77// scheduled in outer strip mined loop78return v + o.intField;79}8081private static class A {82int intField;83public A() {}84}8586private static class B extends A {87public B() {}88}89}909192