RFR: 8331090: Run Ideal_minmax before de-canonicalizing CMoves
Jasmine Karthikeyan
jkarthikeyan at openjdk.org
Mon Jul 1 13:53:19 UTC 2024
On Mon, 1 Jul 2024 05:52:46 GMT, Tobias Hartmann <thartmann at openjdk.org> wrote:
>> Hi all,
>> This patch aims to solve some CMove min/max patterns not being recognized due to the BoolNode comparison being non-canonical, as was reported in [#18824](https://github.com/openjdk/jdk/pull/18824). This can occur due to other Ideal transforms done by CMoves, such as in [here](https://github.com/openjdk/jdk/blob/efb905e57ab7a5299952419fa9961316541056c2/src/hotspot/share/opto/movenode.cpp#L95-L97) and [here](https://github.com/openjdk/jdk/blob/efb905e57ab7a5299952419fa9961316541056c2/src/hotspot/share/opto/movenode.cpp#L274-L278). These transforms move constants and zero-types to the right hand side of the CMove by flipping the comparison, potentially de-canonicalizing it. These invariants are used later on in the [ad files](https://github.com/openjdk/jdk/blob/efb905e57ab7a5299952419fa9961316541056c2/src/hotspot/cpu/x86/x86_64.ad#L6127-L6130) to emit more optimized assembly for these patterns. Since these existing patterns are useful to have, I think the best way to solve this would
be to move `Ideal_minmax` before the branches are swapped and the BoolNode is negated. This should increase the set of inputs that the idealization is able to transform.
>>
>> Tier 1-3 testing passes on my machine. Reviews and comments would be appreciated!
>
> Looks good to me. I submitted testing and will report back once it passed.
Thank you for the review @TobiHartmann!
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19914#issuecomment-2200215529
More information about the hotspot-compiler-dev
mailing list