RFR: 8309902: C2: assert(false) failed: Bad graph detected in build_loop_late after JDK-8305189

Roland Westrelin roland at openjdk.org
Thu Jun 29 15:09:06 UTC 2023


On Wed, 28 Jun 2023 18:24:31 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

>> The crash happens after the following steps:
>> 
>> 1- pre/main/post loops are created with assert predicates above the main loop.
>> 
>> 2- the main loop is peeled
>> 
>> 3- as a consequence, the `OpaqueZeroTripGuard` for the main loop is removed
>> 
>> 4- That allows narrowing of the type of the CastII that was added right
>>   after the zero trip guard during pre/main/post loops creation
>>   
>> 5- The CastII feeds into a range check CastII for the peeled iteration
>>   that becomes top because the narrowed type of the first CastII
>>   conflicts with the type recorded in the range check CastII.
>>   
>> 6- The assert predicate that should fold to protect the range check
>>   CastII doesn't because of the fix for JDK-8282592: on assert
>>   predicate updates, the CastII at the zero trip guard is skipped. So
>>   the range check CastII sees the narrowing of the type of the CastII
>>   at the zero trip guard but the assert predicate doesn't.
>>   
>> The fix I propose is to revert that part of the change from
>> JDK-8282592 so both the range check CastII and the assert predicate
>> have the CastII at the zero trip guard as input and observe its type
>> updates. I went back to that bug and tried to reproduce the failure
>> again but couldn't. Reverting JDK-8281429 causes the bug to reproduce
>> again. I tried tweaking the test so the crash reproduces with
>> JDK-8281429 applied but couldn't.
>> 
>> This is caused by JDK-8305189 because step 3- happens because of
>> it. Before JDK-8305189, 3- happened after loop opts are over. I think
>> what happened then was that a template assertion predicate that was in
>> the process of having its `OpaqueLoopInit` and `OpaqueLoopStride`
>> removed constant folded so the crash wouldn't reproduce.
>
> Looks good.

@vnkozlov @chhagedorn thanks for the reviews

-------------

PR Comment: https://git.openjdk.org/jdk/pull/14672#issuecomment-1613344510


More information about the hotspot-compiler-dev mailing list