Path: blob/master/test/hotspot/jtreg/compiler/loopstripmining/AntiDependentLoadInOuterStripMinedLoop.java
41152 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 822948326* @summary Sinking load out of loop may trigger: assert(found_sfpt) failed: no node in loop that's not input to safepoint27*28* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:-UseOnStackReplacement -XX:LoopMaxUnroll=0 AntiDependentLoadInOuterStripMinedLoop29*30*/3132public class AntiDependentLoadInOuterStripMinedLoop {33private static int field;34private static volatile int barrier;3536public static void main(String[] args) {37int[] array = new int[1];38A a = new A();39for (int i = 0; i < 20_000; i++) {40test1(array);41test2(a, array);42test2_helper(array, 0, 0);43}44}4546private static int test1(int[] array) {47int res = 1;4849for (int i = 0; i < 10; i++) {50barrier = 1;51// field load doesn't float higher than here5253for (int j = 0; j < 2000; j++) {54array[0] = j; // seen as anti dependence by C2 during loop opts, sunk out of loop55res *= j;56}57}5859return field + res + field * 2;60}6162private static int test2(A a, int[] array) {63int ignore = a.field;64int res = 1;6566int k = 0;67for (k = 0; k < 2; k++) {68}6970for (int i = 0; i < 10; i++) {71barrier = 1;7273for (int j = 0; j < 2000; j++) {74test2_helper(array, k, j);75res *= j;76}77}7879return a.field + res + a.field * 2;80}8182private static void test2_helper(int[] array, int k, int j) {83if (k == 2) {84array[0] = j;85}86}8788private static class A {89public int field;90}91}929394