RFR: 8307513: C2: intrinsify Math.max(long,long) and Math.min(long,long) [v11]

Roland Westrelin roland at openjdk.org
Thu Feb 13 16:46:16 UTC 2025


On Thu, 13 Feb 2025 11:46:35 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

> Do we see any other wins with your patch, that are not due to vectorization, but just scalar code?

I think there are some. 

The current transformation from the parsed version of min/max to a conditional move to a `Max`/`Min` node depends on the conditional move transformation which has its own set of heuristics and while it happens on simple test cases, that's not necessarily the case on all code shapes. I don't think we want to trust it too much.

With the intrinsic, the type of the min or max can be narrowed down in a way it can't be whether the code includes control flow or a conditional move. That in turn, once types have propagated, could cause some constant to appear and could be a significant win.

The `Min`/`Max` nodes are floating nodes. They can hoist out of loop and common reliably in ways that are not guaranteed  otherwise.

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

PR Comment: https://git.openjdk.org/jdk/pull/20098#issuecomment-2657176312


More information about the core-libs-dev mailing list