RFR: 8306042: C2: failed: Missed optimization opportunity in PhaseCCP (adding LShift->Cast->Add notification) [v4]

Christian Hagedorn chagedorn at openjdk.org
Fri Apr 28 06:59:55 UTC 2023


On Fri, 28 Apr 2023 06:51:23 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> An other case of `uncast` not being type-propagated through.
>> 
>> We have a case like this:
>> `Phi -> ShiftL -> CastII -> AndI`
>> 
>> The Phi has an updated type, so we should re-run Value on the AndI.
>> 
>> In PhaseCCP::push_and, we do update a similar pattern:
>> `X -> ShiftL -> AndI`
>> 
>> I extended it to handle this pattern:
>> `parent -> LShift (use) -> ConstraintCast* -> And`
>> 
>> For this, I implemented:
>> https://github.com/openjdk/jdk/blob/26f4adaae901822bea984b926c06d1a78f9c6b48/src/hotspot/share/opto/castnode.hpp#L73-L78
>> 
>> I could refactor code from a previous similar fix, for pattern: `ConstraintCast+ -> Sub/Phi`
>> 
>> **Discussion**
>> 
>> https://github.com/openjdk/jdk/blob/4d350f8f4eaabb18482c7656cb56a734e60187cf/src/hotspot/share/opto/castnode.hpp#L78-L79
>> I would have liked to place a `ResourceMark` between these two lines, to ensure the `internals` data structure is de-allocated after the traversal. But if I add it there, then one cannot modify any outer data-structure, or else one risks re-allocation of the outer data-structure in the inner ResourceMark, and then this memory gets de-allocated once the ResourceMark is cleared, and the outer data-structure is broken. This would for example mean that I could not push to the IGVN worklist inside the callback.
>> 
>> Not having the ResourceMark means a memory leak, until the compile phase is over. But my code is not the only place, there are lots of places where we create a Resource allocated data-structure, but do not use ResourceMarks.
>
> Emanuel Peter has updated the pull request incrementally with one additional commit since the last revision:
> 
>   CCP worklist on local arena

Update looks good!

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

Marked as reviewed by chagedorn (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/13611#pullrequestreview-1405324451


More information about the hotspot-compiler-dev mailing list