RFR: JDK-8153837: AArch64: Handle special cases for MaxINode & MinINode [v2]
Xiaohong Gong
xgong at openjdk.org
Tue Dec 20 02:09:53 UTC 2022
On Mon, 19 Dec 2022 08:22:20 GMT, Dmitry Chuyko <dchuyko at openjdk.org> wrote:
>> src/hotspot/cpu/aarch64/aarch64.ad line 13856:
>>
>>> 13854: cmovI_reg_imm0_lt(dst, src, cr);
>>> 13855: %}
>>> 13856: %}
>>
>> It sounds more sense to me if the ideal can make sure the constant input is the right child like what you did in the last commit. So that we only need the first rule like other commutative ops.
>
>> It sounds more sense to me if the ideal can make sure the constant input is the right child like what you did in the last commit. So that we only need the first rule like other commutative ops.
>
> To achieve that we will have to change max(max[...]) and max(add[...]) optimizations. For example the latter likely will have to look into both inputs. I.e. if we order Max to the left and Con to the right, Add can appear at any side etc. - any fixed order for 2 of 3 means not guaranteed order for the third one.
So how about doing the constant swap at the start of the `ideal`, before all other optimizations (i.e. `max(max[...])` and `max(add[...])`). I think it can also benefit other optimizations. E.g. for this optimization:
MaxI1(MaxI2(a, b), c) ==> MaxI1(a, MaxI2(b, c))
If "`b`" is a constant in `MaxI2(a, b)`, and `c` is a constant in `MaxI1(...)`, After the above optimization, `MaxI2(b, c)` can be constant folding into a constant, which is good. But without the constant swap, (i.e. `b` and `c` may not be a constant), the constant folding will be missed for some cases.
-------------
PR: https://git.openjdk.org/jdk/pull/11570
More information about the hotspot-compiler-dev
mailing list