Skip to content

Commit 3934fe5

Browse files
committedNov 8, 2021
8275847: Scheduling fails with "too many D-U pinch points" on small method
Reviewed-by: thartmann, kvn
1 parent 44047f8 commit 3934fe5

File tree

4 files changed

+79
-15
lines changed

4 files changed

+79
-15
lines changed
 

‎src/hotspot/cpu/x86/vmreg_x86.hpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,13 @@ inline bool is_concrete() {
9090
#ifndef AMD64
9191
if (is_Register()) return true;
9292
#endif // AMD64
93-
return is_even(value());
93+
// Do not use is_XMMRegister() here as it depends on the UseAVX setting.
94+
if (value() >= ConcreteRegisterImpl::max_fpr && value() < ConcreteRegisterImpl::max_xmm) {
95+
int base = value() - ConcreteRegisterImpl::max_fpr;
96+
return base % XMMRegisterImpl::max_slots_per_register == 0;
97+
} else {
98+
return is_even(value()); // General, float, and K registers are all two slots wide
99+
}
94100
}
95101

96102
#endif // CPU_X86_VMREG_X86_HPP

‎src/hotspot/share/opto/buildOopMap.cpp

+4-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2002, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -231,10 +231,6 @@ OopMap *OopFlow::build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, i
231231

232232
VMReg r = OptoReg::as_VMReg(OptoReg::Name(reg), framesize, max_inarg_slot);
233233

234-
if (false && r->is_reg() && !r->is_concrete()) {
235-
continue;
236-
}
237-
238234
// See if dead (no reaching def).
239235
Node *def = _defs[reg]; // Get reaching def
240236
assert( def, "since live better have reaching def" );
@@ -312,14 +308,10 @@ OopMap *OopFlow::build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, i
312308
set_live_bit(live,breg);
313309
// Already missed our turn?
314310
if( breg < reg ) {
315-
if (b->is_stack() || b->is_concrete() || true ) {
316-
omap->set_oop( b);
317-
}
311+
omap->set_oop(b);
318312
}
319313
}
320-
if (b->is_stack() || b->is_concrete() || true ) {
321-
omap->set_derived_oop( r, b);
322-
}
314+
omap->set_derived_oop(r, b);
323315
}
324316

325317
} else if( t->isa_narrowoop() ) {
@@ -347,9 +339,7 @@ OopMap *OopFlow::build_oop_map( Node *n, int max_reg, PhaseRegAlloc *regalloc, i
347339
assert( dup_check[_callees[reg]]==0, "trying to callee save same reg twice" );
348340
debug_only( dup_check[_callees[reg]]=1; )
349341
VMReg callee = OptoReg::as_VMReg(OptoReg::Name(_callees[reg]));
350-
if ( callee->is_concrete() || true ) {
351-
omap->set_callee_saved( r, callee);
352-
}
342+
omap->set_callee_saved(r, callee);
353343

354344
} else {
355345
// Other - some reaching non-oop value

‎src/hotspot/share/opto/output.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -2915,6 +2915,16 @@ void Scheduling::anti_do_def( Block *b, Node *def, OptoReg::Name def_reg, int is
29152915
if( !OptoReg::is_valid(def_reg) ) // Ignore stores & control flow
29162916
return;
29172917

2918+
if (OptoReg::is_reg(def_reg)) {
2919+
VMReg vmreg = OptoReg::as_VMReg(def_reg);
2920+
if (vmreg->is_reg() && !vmreg->is_concrete() && !vmreg->prev()->is_concrete()) {
2921+
// This is one of the high slots of a vector register.
2922+
// ScheduleAndBundle already checked there are no live wide
2923+
// vectors in this method so it can be safely ignored.
2924+
return;
2925+
}
2926+
}
2927+
29182928
Node *pinch = _reg_node[def_reg]; // Get pinch point
29192929
if ((pinch == NULL) || _cfg->get_block_for_node(pinch) != b || // No pinch-point yet?
29202930
is_def ) { // Check for a true def (not a kill)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2021, Arm Limited. All rights reserved.
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
*
6+
* This code is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License version 2 only, as
8+
* published by the Free Software Foundation.
9+
*
10+
* This code is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13+
* version 2 for more details (a copy is included in the LICENSE file that
14+
* accompanied this code).
15+
*
16+
* You should have received a copy of the GNU General Public License version
17+
* 2 along with this work; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*
20+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21+
* or visit www.oracle.com if you need additional information or have any
22+
* questions.
23+
*/
24+
25+
package compiler.c2.irTests;
26+
27+
import jdk.test.lib.Asserts;
28+
import compiler.lib.ir_framework.*;
29+
30+
/*
31+
* @test
32+
* @bug 8275847
33+
* @requires vm.compiler2.enabled
34+
* @summary Test that small method with runtime calls can be scheduled.
35+
* @library /test/lib /
36+
* @run driver compiler.c2.irTests.TestScheduleSmallMethod
37+
*/
38+
public class TestScheduleSmallMethod {
39+
40+
public static void main(String[] args) {
41+
TestFramework framework = new TestFramework();
42+
Scenario schedulerOn = new Scenario(0, "-XX:+OptoScheduling");
43+
Scenario schedulerOff = new Scenario(1, "-XX:-OptoScheduling");
44+
framework.addScenarios(schedulerOn, schedulerOff).start();
45+
}
46+
47+
@Test
48+
public double testSmallMethodTwoRuntimeCalls(double value) {
49+
// The two intrinsified Math calls below caused the scheduler to
50+
// bail out with "too many D-U pinch points". See bug 8275847.
51+
return Math.log(Math.sin(value));
52+
}
53+
54+
@Run(test = "testSmallMethodTwoRuntimeCalls")
55+
public void checkTestSmallMethodTwoRuntimeCalls() throws Throwable {
56+
Asserts.assertLessThan(testSmallMethodTwoRuntimeCalls(Math.PI/2), 0.00001);
57+
}
58+
}

0 commit comments

Comments
 (0)
Please sign in to comment.