RFR: 8271203: C2: assert(iff->Opcode() == Op_If || iff->Opcode() == Op_CountedLoopEnd || iff->Opcode() == Op_RangeCheck) failed: Check this code when new subtype is added [v3]

Christian Hagedorn chagedorn at openjdk.java.net
Fri Aug 13 12:28:25 UTC 2021


On Fri, 13 Aug 2021 11:41:48 GMT, Yi Yang <yyang at openjdk.org> wrote:

>> Hi, I'm trying to fix [JDK-8271203](https://bugs.openjdk.java.net/browse/JDK-8271203). It's reasonable to unswitch LongCountedLoop, so relax it.
>> 
>> ![image](https://user-images.githubusercontent.com/5010047/127302280-0faa90bb-add7-4639-8c63-49668901f267.png)
>
> Yi Yang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   package

> > I don't think that a `LongCountedLoop` is unswitched here looking at the stack trace but it's rather chosen as unswitch `If`. I had a closer look at it. It seems that the loop
> > ```
> > for (long l1 = i; l1 < 2; ++l1) {
> >      iArrFld[0] += 5;
> > }
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > is peeled once and then the original loop is found to be dead (because it is known that the type of the iv `i` of the outer-most loop is >= 1). From this peeled iteration we only have `403 LongCountedLoopEnd` left which now just acts as a normal `If` node. It looks fine to then simply use this as an unswitch if for unswitching `367 CountedLoop`. So, relaxing the assert to allow a `LongCountedLoopEnd` node in `dominated_by` looks good IMO.
> 
> Hi Christian, I think you are right. As far as I see, after some loop optimizations, loop at line-17 and loop at line-19 are no longer real loops after PhaseIdealLoop2:
> 
> I'm not sure why there are two same loops(B9 and B19-B22) .. but anyway, 403#LongCountedLoopEnd is located in B21, it's not a loop anymore since no backedge found and C2 treats it as a unswitch_iff.

Not sure which lines you refer to in your image. Lines in the JTreg test (they do not match)? And at what point is this image taken? Can you also elaborate more on what you mean by two same loops?

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

PR: https://git.openjdk.java.net/jdk/pull/4920


More information about the hotspot-compiler-dev mailing list