-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8359603: Missed optimization in PhaseIterGVN for redundant ConvX2Y->ConvY2X->ConvX2Y sequences due to missing notification in PhaseIterGVN::add_users_of_use_to_worklist #26368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
da34188
8359603: Add missing notification
benoitmaillard 0202f02
8359603: Add test from fuzzer
benoitmaillard 760f10f
8359603: Add comment explaining the notification
benoitmaillard 08d8360
8359603: Add opcode check on current node
benoitmaillard c829e6c
8359603: Add other similar conversion patterns for which a missing op…
benoitmaillard 425bcac
8359603: Rename test and add cases for other number types with analog…
benoitmaillard 7576633
8359603: Remove switch in tests
benoitmaillard 9c49b04
Merge branch 'master' of https://git.openjdk.org/jdk into JDK-8359603
benoitmaillard 0b3244f
Update test/hotspot/jtreg/compiler/c2/TestEliminateRedundantConversio…
benoitmaillard 10f7986
8359603: Reduce number of iterations in tests
benoitmaillard 2e5efdc
8359603: Add note
benoitmaillard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
test/hotspot/jtreg/compiler/c2/TestEliminateRedundantConversionSequences.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
/* | ||
* @test | ||
* @bug 8359603 | ||
* @summary Redundant ConvX2Y->ConvY2X->ConvX2Y sequences should be | ||
* simplified to a single ConvX2Y operation when applicable | ||
* VerifyIterativeGVN checks that this optimization was applied | ||
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions | ||
* -XX:CompileCommand=compileonly,compiler.c2.TestEliminateRedundantConversionSequences::test* | ||
* -XX:-TieredCompilation -Xbatch -XX:VerifyIterativeGVN=1110 compiler.c2.TestEliminateRedundantConversionSequences | ||
* @run main compiler.c2.TestEliminateRedundantConversionSequences | ||
* | ||
*/ | ||
|
||
package compiler.c2; | ||
|
||
public class TestEliminateRedundantConversionSequences { | ||
static long instanceCountD2L; | ||
static int instanceCoundF2I; | ||
static long instanceCountF2L; | ||
static float instanceCountI2F; | ||
|
||
// ConvD2L->ConvL2D->ConvD2L | ||
static void testD2L(double d) { | ||
int i = 1; | ||
int j = 1; | ||
while (++i < 3) { | ||
for (; 8 > j; ++j) { | ||
instanceCountD2L = (long)d; | ||
d = instanceCountD2L; | ||
} | ||
} | ||
} | ||
|
||
// ConvF2I->ConvI2F->ConvF2I | ||
static void testF2I(float d) { | ||
int i = 1; | ||
int j = 1; | ||
while (++i < 3) { | ||
for (; 8 > j; ++j) { | ||
instanceCoundF2I = (int)d; | ||
d = instanceCoundF2I; | ||
} | ||
} | ||
} | ||
|
||
// ConvF2L->ConvL2F->ConvF2L | ||
static void testF2L(float d) { | ||
int i = 1; | ||
int j = 1; | ||
while (++i < 3) { | ||
for (; 8 > j; ++j) { | ||
instanceCountF2L = (long)d; | ||
d = instanceCountF2L; | ||
} | ||
} | ||
} | ||
|
||
// ConvI2F->ConvF2I->ConvI2F | ||
static void testI2F(int d) { | ||
int i = 1; | ||
int j = 1; | ||
while (++i < 3) { | ||
for (; 8 > j; ++j) { | ||
instanceCountI2F = d; | ||
d = (int)instanceCountI2F; | ||
} | ||
} | ||
} | ||
|
||
public static void main(String[] strArr) { | ||
for (int i = 0; i < 1550; ++i) { | ||
testD2L(1); | ||
} | ||
for (int i = 0; i < 1550; ++i) { | ||
testF2I(1); | ||
} | ||
for (int i = 0; i < 1550; ++i) { | ||
testF2L(1); | ||
} | ||
for (int i = 0; i < 1550; ++i) { | ||
testI2F(1); | ||
} | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thought: Since this is an incomplete list of variations (especially missing, for example, the I2D version while the I2F version is here), should we leave a comment about not being able to trigger issues with the other versions? Otherwise, it could suggest that it was just forgotten.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The notification issue that is solved here only happens with optimizations that have this chain pattern with three nodes (checking the input of the input) and this is specific to conversions that have a loss of precision. ConvI2D is not here because the
ConvI2D->ConvD2I
gets optimized to a NOP already (ConvD2INode::Identity
). But there are also chains for which there is a known optimization and for which I was not able to trigger a missed optimization, so it would make sense to have mention this in any case.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a short note, let me know what you think!