RFR: 8324655: Identify integer minimum and maximum patterns created with if statements [v3]

Emanuel Peter epeter at openjdk.org
Tue Feb 27 10:52:45 UTC 2024


On Tue, 27 Feb 2024 10:38:47 GMT, Quan Anh Mai <qamai at openjdk.org> wrote:

>> @jaskarth 
>>> I think this would be an interesting experiment, I'll try to design a benchmark for this and get back with the results.
>> 
>> Thanks, that would be excellent. This is to make sure that there is no regression. And if there is one, we'd have to see what to do about it.
>> 
>> And thanks for the explanation around `float/double`. Yes, we would probably need additional nodes, or somehow give additional options for the existing ones. But that is out of scope for this RFE 😊
>
> @eme64 Thanks for your explanation, indeed that makes sense as a reason to limit this to `Min`/`Max` nodes only.
> 
> @jaskarth Is there anything preventing the baseline from transforming the patterns into `CMove`s. If no then what is the benefit of looking at the original control flow instead of the transformed 'CMove`?
> 
> Thanks very much.

@merykitty I think the issue is that the `CMove` heuristics are very strict. You basically can have almost nothing in the two branches of the if, otherwise it is not clear that it is profitable to always execute both branches.

Presumably, with `Max/Min` we have a simpler case, with only 2 values instead of 4. But still, there could be a similar issue. And that is why I have asked for the benchmark:

> @jaskarth can you construct a benchmark with a (a cmp b) ? a : b where you now convert to min/max, and we very often take the a branch, and where the b value is quite expensive, and the a value is very cheap? This would be an example where it might be more profitable to speculate on a (cheap), rather than to force computation of b before the min/max can be computed. Not sure how easy it is to write such a benchmark, but I'd love to see it ;)

This would be a possible regression case that we have to somehow deal with.

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

PR Comment: https://git.openjdk.org/jdk/pull/17574#issuecomment-1966279978


More information about the hotspot-compiler-dev mailing list