Integrated: 8306042: C2: failed: Missed optimization opportunity in PhaseCCP (adding LShift->Cast->Add notification)
Emanuel Peter
epeter at openjdk.org
Wed May 3 10:48:26 UTC 2023
On Mon, 24 Apr 2023 11:32:48 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.
This pull request has now been integrated.
Changeset: e9807a4b
Author: Emanuel Peter <epeter at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/e9807a4b0f3533512623fba96042472b69d4ac34
Stats: 128 lines in 3 files changed: 97 ins; 22 del; 9 mod
8306042: C2: failed: Missed optimization opportunity in PhaseCCP (adding LShift->Cast->Add notification)
Reviewed-by: thartmann, chagedorn, kvn
-------------
PR: https://git.openjdk.org/jdk/pull/13611
More information about the hotspot-compiler-dev
mailing list