Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/hotspot/share/opto/phaseX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2566,13 +2566,16 @@ void PhaseIterGVN::add_users_of_use_to_worklist(Node* n, Node* use, Unique_Node_
// ConvI2F->ConvF2I->ConvI2F
// Note: there may be other 3-nodes conversion chains that would require to be added here, but these
// are the only ones that are known to trigger missed optimizations otherwise
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to update the description, and give a bit of extra information. Because you are saying n does not have to be a conversion, but it may be that n is about to be replaced with a conversion, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in some cases add_users_of_use_to_worklist is called with the node about to be replaced as argument n. The point is that we might replace n with a node that already has other uses, and we only want to notify the uses for which there is a potential change.
But this is in no way specific to this one optimization, so I think adding something here would cause more confusion than anything else. Perhaps we should update the description of add_users_of_use_to_worklist then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, this is not specific to this optimization here. Why not add something at the level of add_users_of_use_to_worklist.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, I ended up adding comments to the definition of both add_users_to_worklist and add_users_of_use_to_worklist. I think this might help avoid some confusion in the future.

if ((n->Opcode() == Op_ConvD2L && use_op == Op_ConvL2D) ||
(n->Opcode() == Op_ConvF2I && use_op == Op_ConvI2F) ||
(n->Opcode() == Op_ConvF2L && use_op == Op_ConvL2F) ||
(n->Opcode() == Op_ConvI2F && use_op == Op_ConvF2I)) {
if (use_op == Op_ConvL2D ||
use_op == Op_ConvI2F ||
use_op == Op_ConvL2F ||
use_op == Op_ConvF2I) {
for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) {
Node* u = use->fast_out(i2);
if (u->Opcode() == n->Opcode()) {
if ((use_op == Op_ConvL2D && u->Opcode() == Op_ConvD2L) ||
(use_op == Op_ConvI2F && u->Opcode() == Op_ConvF2I) ||
(use_op == Op_ConvL2F && u->Opcode() == Op_ConvF2L) ||
(use_op == Op_ConvF2I && u->Opcode() == Op_ConvI2F)) {
worklist.push(u);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,19 @@

/*
* @test
* @bug 8359603
* @bug 8359603 8369646
* @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
* -XX:-TieredCompilation -Xbatch -XX:VerifyIterativeGVN=1110
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could either add a separate run with -XX:+StressIGVN without a fixed seed or just add -XX:+StressIGVN here. I guess the latter is good enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, and I just added -XX:+StressIGVN to the existing run.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

* compiler.c2.TestEliminateRedundantConversionSequences
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions
* -XX:CompileCommand=compileonly,compiler.c2.TestEliminateRedundantConversionSequences::test*
* -XX:-TieredCompilation -Xbatch -XX:VerifyIterativeGVN=1110
* -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN -XX:StressSeed=115074401
* compiler.c2.TestEliminateRedundantConversionSequences
* @run main compiler.c2.TestEliminateRedundantConversionSequences
*
*/
Expand Down