RFR: 8370405: C2: mismatched store from MergeStores wrongly scalarized in allocation elimination [v2]

Emanuel Peter epeter at openjdk.org
Wed Oct 29 17:36:49 UTC 2025


On Wed, 29 Oct 2025 17:20:15 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:

> > But now we run MergeStores, and merge two of the StoreI into a mismatched StoreL.
> 
> Since associated allocation is marked as `_is_scalar_replaceable` we should be able to check that before trying to merge stores and avoid this mismatching. This will allow to eliminate allocation.
> 
> I would still keep your check because mismatching may come from different place in a future.

I'm not sure I'm understanding you corretly.
Are you saying we should find a way to do MergeStores after allocation elimination?

@TobiHartmann Suggested I should move MergeStores as late as possible.

I agree we should move MergeStores, but I'm not sure we should do it as part of this fix.
I think it is quite rare that allocation elimination could succeed after loop-opts (and not already before), and that we also succeed with MergeStores.
MergeStores is in since JDK21, and nobody filed a bug report because they noticed a regression (yet).

What do you think?

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

PR Comment: https://git.openjdk.org/jdk/pull/27997#issuecomment-3462815309


More information about the hotspot-compiler-dev mailing list