8373396: Min and Max Ideal missing AddNode::Ideal optimisations#28770
8373396: Min and Max Ideal missing AddNode::Ideal optimisations#28770galderz wants to merge 11 commits intoopenjdk:masterfrom
Conversation
* Optimizations include commutation, flattening, pushing constants...etc. * Added template framework generated test for all optimizations that AddNode::Ideal covers. * Test for ints and longs, both of which call AddNode::Ideal.
|
👋 Welcome back galder! A progress list of the required criteria for merging this PR into |
|
@galderz This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 131 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@eme64, @rwestrel) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
src/hotspot/share/opto/addnode.cpp
Outdated
|
|
||
| // Ideal transformations for MaxINode | ||
| Node* MaxINode::Ideal(PhaseGVN* phase, bool can_reshape) { | ||
| Node* n = AddNode::Ideal(phase, can_reshape); |
There was a problem hiding this comment.
Why not move this into MaxNode::IdealI?
There was a problem hiding this comment.
Yes, the call below return IdealI(phase, can_reshape); already looks like it wants to handle all the superclass optimiazations. So it should go in there.
src/hotspot/share/opto/addnode.cpp
Outdated
|
|
||
| // Ideal transformations for MaxINode | ||
| Node* MaxINode::Ideal(PhaseGVN* phase, bool can_reshape) { | ||
| Node* n = AddNode::Ideal(phase, can_reshape); |
There was a problem hiding this comment.
Yes, the call below return IdealI(phase, can_reshape); already looks like it wants to handle all the superclass optimiazations. So it should go in there.
| * @summary Verify that min/max add ideal optimizations get applied correctly | ||
| * @modules java.base/jdk.internal.misc | ||
| * @library /test/lib / | ||
| * @run driver compiler.c2.irTests.TestMinMaxIdeal |
There was a problem hiding this comment.
| * @run driver compiler.c2.irTests.TestMinMaxIdeal | |
| * @run driver ${test.main.class} |
Also: please don't put any new tests in irTests. Rather put it in a directory based on the topic.
There was a problem hiding this comment.
I did think about that but then I saw TestMinMaxIdentities was on the package so thought of adding it next to it. What about putting it in compiler.intrinsics.math instead?
There was a problem hiding this comment.
I think it belongs more under idealization. So either a gvn or igvn directory.
| String templatedPackage ="compiler.c2.templated"; | ||
| String templatedClassName ="MinMaxIdeal"; | ||
| String templatedFQN = "%s.%s".formatted(templatedPackage, templatedClassName); |
There was a problem hiding this comment.
That looks a bit convoluted. Why not just use the final string?
There was a problem hiding this comment.
Not sure exactly what you mean. For addJavaSourceCode I need the combined FQN and for TestFrameworkClass.render I need the classname and package separated.
There was a problem hiding this comment.
It is just a nit, I leave it to you. I'm also fine taking it as is :)
| testTemplateTokens.add(new TestGenerator(Op.MIN_I).generate()); | ||
| testTemplateTokens.add(new TestGenerator(Op.MAX_I).generate()); | ||
| testTemplateTokens.add(new TestGenerator(Op.MIN_L).generate()); | ||
| testTemplateTokens.add(new TestGenerator(Op.MAX_L).generate()); |
There was a problem hiding this comment.
Why not use Op.values() -> List, then iterate over that?
There was a problem hiding this comment.
Yeah, better indeed. It avoids issues adding an enum value and forgetting to add it (I already did that lol)
|
@TobiHartmann Thanks for the review! @eme64 Thanks also for the review. Can you please also clarify what I said about potentially changing |
I don't remember. Try enabling the verification, and see if you find any test that fails. If not: great, maybe you fixed it! If it still fails, it would be nice if you added more info, but not neccessary. I don't remember because there were eventually too many cases and I stopped reporting which had failed. |
It still fails with other optimisation missing, so I will revert that the commit that uncommented that: |
This reverts commit 1ae3081.
|
I've reverted the @TobiHartmann @eme64 Could you please review it once more? Thanks! |
eme64
left a comment
There was a problem hiding this comment.
Looks good now, except that little nit below.
We can run some internal testing once a second reviewer has had a look :)
| let("irNodeName", op.name()), | ||
| let("boxedTypeName", op.type.boxedTypeName()), | ||
| let("op", op.name()), |
There was a problem hiding this comment.
Nit: you are repeating the same value op.name() with two hashtags op and irNodeName. Is that intentional?
There was a problem hiding this comment.
No, I'll get it fixed
eme64
left a comment
There was a problem hiding this comment.
Nice, looks cleaner now :)
|
@eme64 Roland provided the 2nd review so you can start your internal testing. |
|
Testing launched 🚀 |
|
Testing passed, ship it 🚢 ! |
|
/integrate |
|
/sponsor |
|
Going to push as commit 2c0d9a7.
Your commit was automatically rebased without conflicts. |
MaxIandMinIare missingAddNode::Idealoptimizations. These optimizations include commutation, flattening, pushing constants...etc. The PR changesMaxINode::IdealandMinINode::Idealto callAddNode::Ideal. Long versions already callAddNode::Idealso nothing to change there.The PR also includes a template framework generated test (cc @eme64) that verifies that all of
AddNode::Idealoptimizations 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.javawhen run with-XX:VerifyIterativeGVN=1110, which was failing due tominnot having one of those optimisations. However, this PR does not make changes toPhaseIterGVN::verify_Identity_forbecause 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_forexceptions for MinI/MaxI are still needed.If you look atPhaseIterGVN::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 ?):I've run tier1-3 tests on linux/x64 and they passed.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/28770/head:pull/28770$ git checkout pull/28770Update a local copy of the PR:
$ git checkout pull/28770$ git pull https://git.openjdk.org/jdk.git pull/28770/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 28770View PR using the GUI difftool:
$ git pr show -t 28770Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/28770.diff
Using Webrev
Link to Webrev Comment