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

Jasmine Karthikeyan jkarthikeyan at openjdk.org
Thu Mar 7 18:17:55 UTC 2024


On Thu, 7 Mar 2024 08:45:39 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

>> Jasmine Karthikeyan has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Change transform to work on CMoves
>
> src/hotspot/share/opto/movenode.cpp line 322:
> 
>> 320:   if (phase->C->post_loop_opts_phase()) {
>> 321:     return nullptr;
>> 322:   }
> 
> Putting the condition here would prevent any future optimization further down not to be executed. I think you should rather put this into the `is_minmax` method. Maybe this condition is now only relevant for `long`, but I think it would not hurt to also have it also for `int`, right?

That's a good point, I think this will make the logic cleaner. I don't think it'll hurt it to have it for int either.

> test/hotspot/jtreg/compiler/c2/irTests/TestIfMinMax.java line 139:
> 
>> 137:     public long testMaxL2E(long a, long b) {
>> 138:         return a <= b ? b : a;
>> 139:     }
> 
> I assume some of the `long` patterns should also have become MaxL/MinL in some phase, right? Is there maybe some phase where the IR would actually show that? You can target the IR rule to a phase, I think. Would be worth a try.

Oh true, I think we can identify MinL/MaxL before macro expansion is done.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/17574#discussion_r1516615194
PR Review Comment: https://git.openjdk.org/jdk/pull/17574#discussion_r1516616923


More information about the hotspot-compiler-dev mailing list