-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8351515: C2 incorrectly removes double negation for double and float #24150
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
Conversation
|
👋 Welcome back mhaessig! A progress list of the required criteria for merging this PR into |
|
@mhaessig 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 22 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 (@chhagedorn, @TobiHartmann) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Webrevs
|
chhagedorn
left a comment
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.
Looks good to me. Nice to also see a Float16 IR test :-)
|
Negation here can be a bit of a confusing term since the JLS § 15.15.4 says:
This is also the reason why NegF/D nodes are used separately (NegI/L nodes exist but seem to be unused). The change itself looks good, but maybe it's worth to clarify the comment? Or somehow reference the comment here: jdk/src/hotspot/share/opto/subnode.hpp Lines 473 to 478 in b32be18
|
|
@SirYwell thanks for the pointer to the negation section of the spec. I improved the comment by referencing spec and differentiating subtraction from negation. |
TobiHartmann
left a comment
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.
Looks good to me otherwise!
Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
|
Thanks for the review and helpful comments everyone! /integrate |
|
/sponsor |
|
Going to push as commit 5591f8a.
Your commit was automatically rebased without conflicts. |
|
@TobiHartmann @mhaessig Pushed as commit 5591f8a. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Issue Summary
A fuzzer run discovered that code of the form
0 - (0 - x)yields the wrong result forx = -0.0. According to the Java Language Spec 15.8.2 the sum of floating point zeroes of opposite sign is positive zero. Hence,(0 - (0 - (-0.0))must result in+0.0, but due to the folding of all double negations inSubNode::Identitythis was optimized to-0.0Changeset overview
To fix this issue, I excluded floating point numbers from the folding of double negations, which also includes
Float16values. This might seem excessive at first glance, but we do not track range information for floating point types. Hence, we could still perform the folding of the double negation if a floating point constant is not-0.0. However, constant folding already takes care of this.Changes:
IRNode.SUBnot matchingSubHFNodeSubNodesfrom folding double negationsTesting
tier1throughtier5plus Oracle internal testingProgress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24150/head:pull/24150$ git checkout pull/24150Update a local copy of the PR:
$ git checkout pull/24150$ git pull https://git.openjdk.org/jdk.git pull/24150/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24150View PR using the GUI difftool:
$ git pr show -t 24150Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24150.diff
Using Webrev
Link to Webrev Comment