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

Emanuel Peter epeter at openjdk.org
Fri Apr 28 06:51:23 UTC 2023


> 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

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/13611/files
  - new: https://git.openjdk.org/jdk/pull/13611/files/f4df73bd..4d2a4f9e

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=13611&range=03
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=13611&range=02-03

  Stats: 7 lines in 1 file changed: 6 ins; 1 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/13611.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/13611/head:pull/13611

PR: https://git.openjdk.org/jdk/pull/13611


More information about the hotspot-compiler-dev mailing list