Path: blob/master/test/hotspot/jtreg/compiler/loopopts/TestCMovSplitThruPhi.java
41149 views
/*1* Copyright (c) 2017, 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 818782226* @summary C2 conditonal move optimization might create broken graph27* @requires vm.flavor == "server"28* @run main/othervm -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestCMovSplitThruPhi::not_inlined -XX:CompileOnly=TestCMovSplitThruPhi::test -XX:-LoopUnswitching TestCMovSplitThruPhi29*30*/3132public class TestCMovSplitThruPhi {33static int f;3435static int test(boolean flag1, boolean flag2, boolean flag3, boolean flag4) {36int v3 = 0;37if (flag4) {38for (int i = 0; i < 10; i++) {39int v1 = 0;40if (flag1) {41v1 = not_inlined();42}43// AddI below will be candidate for split through Phi44int v2 = v1;45if (flag2) {46v2 = f + v1;47}48// test above will be converted to CMovI49if (flag3) {50v3 = v2 * 2;51break;52}53}54}55return v3;56}5758private static int not_inlined() {59return 0;60}6162public static void main(String[] args) {63for (int i = 0; i < 20000; i++) {64test((i % 2) == 0, (i % 2) == 0, (i % 100) == 1, (i % 1000) == 1);65}66}67}686970