[11] RFR(S): 8202949: C2: assert(false) failed: Bad graph detected in build_loop_late

Tobias Hartmann tobias.hartmann at oracle.com
Wed May 23 13:51:37 UTC 2018


On 23.05.2018 15:09, Roland Westrelin wrote:
> Where does the ConvI2L move up to?
> It's dependent on the induction variable so it can't go very far?

Right, I think the point is more that the type of the ConvI2L is narrowed which is usually prevented
by the CastII where we do not allow the type to be narrowed in case it is range check dependent.

In general, the problem is that if we narrow the type of a range check dependent CastII/ConvI2L
(without narrowing the range check as well), the CastII/ConvI2L might go away while the dead control
path is still there.

> Are we talking about the main loop after unrolling?

Here are the steps that lead to the ConvI2L being replaced by TOP:

After parsing:
 175	CastII	===  163  131  [[ 176 ]]  #int:0..9:www range check dependency !jvms: SimpleTest::test @
bci:27
 176	ConvI2L	=== _  175  [[]]  #long:0..9:www !jvms: SimpleTest::test @ bci:27

ConstraintCastNode::Identity then removes the CastII because the loop phi has a narrow type:

 326	CountedLoop	===  326  125  324  [[ 326  142  131  128  129  130 ]] stride: -1
!orig=[311],[126] !jvms: SimpleTest::test @ bci:22
 131	Phi	===  326  95  320  [[ 252  320  146  175  168  160  168 ]]  #int:6..8 #tripcount !orig=175
!jvms: SimpleTest::test @ bci:22
 176	ConvI2L	=== _  131  [[]]  #long:0..9:www !jvms: SimpleTest::test @ bci:27

After loop cloning/unrolling (131 Phi -> 495 Phi, 176 ConvI2L -> 494 ConvI2L) the type of the
ConvI2L is narrowed as well:

 472	CountedLoop	===  472  511  324  [[ 458  465  466  468  472  473  495 ]] inner stride: -2 main
of N472 !orig=[326],[311],[126] !jvms: SimpleTest::test @ bci:22
 495	Phi	===  472  449  320  [[ 456  494  320 ]]  #int:<=7:www #tripcount !orig=131,[175] !jvms:
SimpleTest::test @ bci:22
 494	ConvI2L	=== _  495  [[ 461 ]]  #long:6..8 !orig=[176] !jvms: SimpleTest::test @ bci:27

Later:

 554	CountedLoop	===  554  511  324  [[ 531  544  551  554  556  557  568 ]] inner main of N554
!orig=[472],[326],[311],[126] !jvms: SimpleTest::test @ bci:22
 514	ConI	===  0  [[ 543 ]]  #int:-2
 556	Phi	===  554  449  320  [[ 543  555  320 ]]  #int:5..7 !orig=495,131,[175] !jvms:
SimpleTest::test @ bci:22
 543	AddI	=== _  556  514  [[ 494 ]]  !orig=320,[266] !jvms: SimpleTest::test @ bci:75
 494	ConvI2L	=== _  543  [[ 461 ]]  #top !orig=[176] !jvms: SimpleTest::test @ bci:27

The ConvI2L is replaced by TOP because the type of the input AddI is 3..5 which does not intersect
with 6..8. This does not happen with the CastII in place because we don't allow it's type to be
narrowed if it's range check dependent.

This is similar to what I've fixed with JDK-8177095 [1]

Thanks,
Tobias

[1] http://cr.openjdk.java.net/~thartmann/8177095/webrev.00/


More information about the hotspot-compiler-dev mailing list