RFR: 8324655: Identify integer minimum and maximum patterns created with if statements [v3]
Quan Anh Mai
qamai at openjdk.org
Tue Feb 27 17:34:53 UTC 2024
On Tue, 27 Feb 2024 17:19:06 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> @eme64 I thought the merged values are the ones used in the comparison, which means that the 2 branches are empty? Maybe there are cases that I am missing here?
>
> @merykitty I am thinking of a case like this:
>
> a = <something very expensive>
> b = <something cheap>
> x = (a < b) ? a : b;
>
> If in most cases we take `b` (because it is larger), then we might speculatively assign `x = b`, before we have finished computing `a`. That way we can already continue (speculatively) with `x = b`, while `a` is still computing. If the speculation is wrong, then the CPU flushes the pipeline.
>
> If this is converted to `max/min`, then we need to wait for `a` to be computed.
>
> @merykitty @jaskarth does this make sense as an example for a potential performance regression?
@eme64 Thanks for making that clear. I'm asking @jaskarth if it is easier to transform a `CMove` into a `Min`/`Max` instead of trying to look for matching `Phi`s.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/17574#issuecomment-1967261106
More information about the hotspot-compiler-dev
mailing list