RFR: 8373396: Min and Max Ideal missing AddNode::Ideal optimisations [v3]
Emanuel Peter
epeter at openjdk.org
Tue Dec 16 07:42:15 UTC 2025
On Mon, 15 Dec 2025 17:21:17 GMT, Galder Zamarreño <galder at openjdk.org> wrote:
>> `MaxI` and `MinI` are missing `AddNode::Ideal` optimizations. These optimizations include commutation, flattening, pushing constants...etc. The PR changes `MaxINode::Ideal` and `MinINode::Ideal` to call `AddNode::Ideal`. Long versions already call `AddNode::Ideal` so nothing to change there.
>>
>> The PR also includes a template framework generated test (cc @eme64) that verifies that all of `AddNode::Ideal` optimizations now apply correctly for min/max for longs and ints. Long tests have been added to validate that both ints and longs produce the same results.
>>
>> Fixing this issue indirectly fixes `compiler/codegen/TestBooleanVect.java` when run with `-XX:VerifyIterativeGVN=1110`, which was failing due to `min` not having one of those optimisations. However, this PR does not make changes to `PhaseIterGVN::verify_Identity_for` because there are additional failures observed with min/max for integers in JDK-8373134. Therefore, changes there will in the PR for JDK-8373134 instead.
>>
>> **Update 15.12.25**: `PhaseIterGVN::verify_Ideal_for` exceptions for MinI/MaxI are still needed.
>>
>> ~If you look at `PhaseIterGVN::verify_Ideal_for`, it contains. This looks like it could be removed in this PR as it looks like they were quite likely disabled due to the issue here. However, it's unclear what test was failing here (@eme64 ?):~
>>
>>
>> // MinINode::Ideal
>> // Did not investigate, but there are some patterns that might
>> // need more notification.
>> case Op_MinI:
>> case Op_MaxI: // preemptively removed it as well.
>> return false;
>>
>>
>> I've run tier1-3 tests on linux/x64 and they passed.
>
> Galder Zamarreño has updated the pull request incrementally with one additional commit since the last revision:
>
> Revert "Remove MinI/MaxI exceptions from verify_Ideal_for"
>
> This reverts commit 1ae308155ebec12a9741eb40b1630dbde49af7ac.
Looks good now, except that little nit below.
We can run some internal testing once a second reviewer has had a look :)
test/hotspot/jtreg/compiler/igvn/TestMinMaxIdeal.java line 101:
> 99: let("irNodeName", op.name()),
> 100: let("boxedTypeName", op.type.boxedTypeName()),
> 101: let("op", op.name()),
Nit: you are repeating the same value `op.name()` with two hashtags `op` and `irNodeName`. Is that intentional?
-------------
Marked as reviewed by epeter (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/28770#pullrequestreview-3581735166
PR Review Comment: https://git.openjdk.org/jdk/pull/28770#discussion_r2622145391
More information about the hotspot-compiler-dev
mailing list