RFR: 8306042: C2: failed: Missed optimization opportunity in PhaseCCP (adding LShift->Cast->Add notification)
Emanuel Peter
epeter at openjdk.org
Tue Apr 25 06:24:11 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.
-------------
Commit messages:
- Remove ResourceMark, which lead to bad de-allocations
- spurious new line
- 8306042: C2: failed: Missed optimization opportunity in PhaseCCP (adding LShift->Cast->Add notification)
Changes: https://git.openjdk.org/jdk/pull/13611/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=13611&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8306042
Stats: 118 lines in 3 files changed: 89 ins; 20 del; 9 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