-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8364407: [REDO] Consolidate Identity of self-inverse operations #26823
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
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
@Test | ||
@IR(counts = {IRNode.REVERSE_BYTES_S, "2"}) |
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'm not sure if this is fine. The intrinsics might not apply to all platforms, in which case this would fail I think?
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 only case I can immediately think of is riscv without -XX:+UseZbb
. But you can easily disable the test for that platform.
👋 Welcome back hgreule! A progress list of the required criteria for merging this PR into |
❗ This change is not yet ready to be integrated. |
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.
Thank you for noticing the bug and improving your original PR, @SirYwell! I like your new approach without a superclass and your extensive testing of all edge cases and random values. Nice work!
However, I do have some questions below.
* @summary Test that Identity simplifications of Involution nodes are being performed as expected. | ||
* @library /test/lib / |
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.
* @summary Test that Identity simplifications of Involution nodes are being performed as expected. | |
* @library /test/lib / | |
* @summary Test that Identity simplifications of Involution nodes are being performed as expected. | |
* @key randomness | |
* @library /test/lib / |
Since you are using random inputs.
// Operations on sub-int types might not be "real" involutions for values outside their type range. | ||
// Make sure not to drop potential truncations. | ||
if (type == nullptr || involution->bottom_type()->is_int()->contains(type)) { | ||
return involution->in(1)->in(1); | ||
} |
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.
Instead of skipping the optimization, could you "clean" involution->in(1)->in(1)
using mask_int_value()
? That would follow the semantics of JVMS§6.5 ireturn
.
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 think this would need to happen in Ideal()
then instead. Doing that would work too, but it further complicates things with little benefits imo.
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.
Why are you not testing involution on NegL/I
nodes? Can this not be optimized?
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.
NegL/I
aren't used currently (see e.g. https://bugs.openjdk.org/browse/JDK-8262346).
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.
This looks nice! I've just left some style comments.
static Node* simplify_involution(PhaseGVN* phase, Node* involution) { | ||
if (involution->in(1)->Opcode() == involution->Opcode()) { | ||
Node* original = involution->in(1)->in(1); | ||
const TypeInt *type = phase->type(original)->isa_int(); |
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.
const TypeInt *type = phase->type(original)->isa_int(); | |
const TypeInt* type = phase->type(original)->isa_int(); |
|
||
} |
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.
There's an extra whitespace:
} | |
} |
if (involution->in(1)->Opcode() == involution->Opcode()) { | ||
Node* original = involution->in(1)->in(1); | ||
const TypeInt *type = phase->type(original)->isa_int(); | ||
// Operations on sub-int types might not be "real" involutions for values outside their type range. |
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 think it would be helpful to state an example of the disallowed case in the comment, maybe something like:
// Operations on sub-int types might not be "real" involutions for values outside their type range. | |
// Operations on sub-int types might not be "real" involutions for values outside their type range, for example a ReverseBytesS node with an input larger than short. |
The previous approach was flawed for
short
andchar
as these are int-subtypes and truncate the result (see the backout issue https://bugs.openjdk.org/browse/JDK-8364409 for a reproducer).This change now first ensures that the input type is small enough so no truncation gets lost when dropping the operations.
The previous implementation also used an
InvolutionNode
superclass with oneIdentity(...)
implementation, but there were some reservations whether this is the right way to go. As we now have aReverseBytesNode
, there is also less benefit in having the supertype, as this covers 4 in 1 already.I also added test cases on top of the original ones that ensure the nodes stay when we can't prove the input type is small enough.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26823/head:pull/26823
$ git checkout pull/26823
Update a local copy of the PR:
$ git checkout pull/26823
$ git pull https://git.openjdk.org/jdk.git pull/26823/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26823
View PR using the GUI difftool:
$ git pr show -t 26823
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26823.diff
Using Webrev
Link to Webrev Comment