diff --git a/src/hotspot/share/opto/loopopts.cpp b/src/hotspot/share/opto/loopopts.cpp index 56f03466616..b603e604578 100644 --- a/src/hotspot/share/opto/loopopts.cpp +++ b/src/hotspot/share/opto/loopopts.cpp @@ -795,18 +795,25 @@ Node *PhaseIdealLoop::conditional_move( Node *region ) { // Avoid duplicated float compare. if (phis > 1 && (cmp_op == Op_CmpF || cmp_op == Op_CmpD)) return nullptr; - // Ignore cost if CMOVE can be moved outside the loop. - if (used_inside_loop && cost >= ConditionalMoveLimit) { - return nullptr; + float infrequent_prob = PROB_UNLIKELY_MAG(3); + // Ignore cost and blocks frequency if CMOVE can be moved outside the loop. + if (used_inside_loop) { + if (cost >= ConditionalMoveLimit) return nullptr; // Too much goo + + // BlockLayoutByFrequency optimization moves infrequent branch + // from hot path. No point in CMOV'ing in such case (110 is used + // instead of 100 to take into account not exactness of float value). + if (BlockLayoutByFrequency) { + infrequent_prob = MAX2(infrequent_prob, (float)BlockLayoutMinDiamondPercentage/110.0f); + } } // Check for highly predictable branch. No point in CMOV'ing if // we are going to predict accurately all the time. - constexpr float infrequent_prob = PROB_UNLIKELY_MAG(2); if (C->use_cmove() && (cmp_op == Op_CmpF || cmp_op == Op_CmpD)) { //keep going - } else if (iff->_prob < infrequent_prob || iff->_prob > (1.0f - infrequent_prob)) { + } else if (iff->_prob < infrequent_prob || + iff->_prob > (1.0f - infrequent_prob)) return nullptr; - } // -------------- // Now replace all Phis with CMOV's diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index c1b7551f7d5..a3d27d47b84 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -67,6 +67,7 @@ compiler/c2/Test8004741.java 8235801 generic-all compiler/c2/TestMergeStores.java#id0 8331311 generic-ppc64,linux-s390x compiler/c2/TestMergeStores.java#id1 8331311 generic-ppc64,linux-s390x compiler/c2/irTests/TestDuplicateBackedge.java 8318904 generic-all +compiler/c2/irTests/TestIfMinMax.java 8334816 generic-all compiler/codecache/jmx/PoolsIndependenceTest.java 8264632 macosx-all compiler/codecache/CheckLargePages.java 8332654 linux-x64 diff --git a/test/micro/org/openjdk/bench/vm/compiler/CMove.java b/test/micro/org/openjdk/bench/vm/compiler/CMove.java deleted file mode 100644 index 0f92a681c72..00000000000 --- a/test/micro/org/openjdk/bench/vm/compiler/CMove.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package org.openjdk.bench.vm.compiler; - -import java.util.concurrent.TimeUnit; -import java.util.random.RandomGeneratorFactory; -import org.openjdk.jmh.annotations.*; -import org.openjdk.jmh.infra.Blackhole; - -@BenchmarkMode(Mode.AverageTime) -@OutputTimeUnit(TimeUnit.MICROSECONDS) -@State(Scope.Thread) -@Warmup(iterations = 5, time = 1) -@Measurement(iterations = 5, time = 1) -@Fork(value = 1) -public class CMove { - static final int SIZE = 1000000; - - @Param({"0.003", "0.006", "0.01", "0.02", "0.03", "0.06", "0.1", "0.2", "0.3", "0.6"}) - double freq; - - boolean[] conds; - - @Setup(Level.Iteration) - public void setup() { - var r = RandomGeneratorFactory.getDefault().create(1); - conds = new boolean[SIZE]; - for (int i = 0; i < SIZE; i++) { - conds[i] = r.nextDouble() < freq; - } - } - - @Benchmark - public void run(Blackhole bh) { - for (int i = 0; i < conds.length; i++) { - bh.consume(conds[i] ? 2 : 1); - } - } -} \ No newline at end of file