-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8322490: cleanup CastNode construction #17162
Conversation
👋 Welcome back caojoshua! A progress list of the required criteria for merging this PR into |
@caojoshua The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
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 that's a good idea but you've missed some cases of creating new CastIINodes
that could use the control-based constructor.
Example (there are more cases when you search for "new CastIINode"):
jdk/src/hotspot/share/opto/loopTransform.cpp
Lines 3164 to 3166 in f7dc257
main_limit = new CastIINode(main_limit, TypeInt::make(upward ? min_jint : orig_limit_t->_lo, | |
upward ? orig_limit_t->_hi : max_jint, Type::WidenMax)); | |
main_limit->init_req(0, pre_ctrl); |
src/hotspot/share/opto/castnode.cpp
Outdated
@@ -126,37 +126,20 @@ uint ConstraintCastNode::size_of() const { | |||
Node* ConstraintCastNode::make_cast(int opcode, Node* c, Node* n, const Type* t, DependencyType dependency, |
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 wondering if this method is still worth keeping as it would simply replace a "new CastXXNode" line which is just as expressive/readable. As far as I can see, it's currently only used with statically known Opcodes. So, we could replace them.
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.
On a separate note and might be worth to do in this change as well, we have ConstraintCastNode::make_cast_for_type()
and ConstraintCastNode::make()
. The intent of the former is clear but the latter switches on the provided basic type. Maybe we can rename the latter to make_cast_for_basic_type()
to better align it with make_cast_for_type()
.
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.
Agree that make_cast
probably is not needed. And your renaming suggestion makes sense.
Can we have this in a separate PR? I generally prefer to keep PRs as small of a unit as possible.
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.
If you change the title of the PR into something like "cleanup CastNode construction" then I guess it's fine to do it all in once. But I leave it up to you to decide if you want to split it or not. Both is fine.
// Make the CastII node dependent on the control input to prevent the narrowed ConvI2L | ||
// node from floating above the range check during loop optimizations. Otherwise, the | ||
// ConvI2L node may be eliminated independently of the range check, causing the data path | ||
// to become TOP while the control path is still there (although it's unreachable). |
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.
Might be cleaner to move this comment block above the creation of the cast node
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.
Otherwise, the cleanup looks good.
@caojoshua 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 67 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, @phohensee) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@caojoshua |
@chhagedorn, Josh applied your requested changes, please re-review. |
@chhagedorn I changed my mind. Added the make_cast cleanups to this PR as well. |
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.
Otherwise, the update looks good! You can directly integrate/get it sponsored afterward.
src/hotspot/share/opto/castnode.cpp
Outdated
} | ||
|
||
Node* ConstraintCastNode::make(Node* c, Node *n, const Type *t, DependencyType dependency, BasicType bt) { | ||
Node* ConstraintCastNode::make_cast_for_basic_type(Node* c, Node *n, const Type *t, DependencyType dependency, BasicType bt) { |
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.
While at it, you can also fix the asterisk positions:
Node* ConstraintCastNode::make_cast_for_basic_type(Node* c, Node *n, const Type *t, DependencyType dependency, BasicType bt) { | |
Node* ConstraintCastNode::make_cast_for_basic_type(Node* c, Node* n, const Type* t, DependencyType dependency, BasicType bt) { |
@@ -1140,7 +1139,9 @@ bool LibraryCallKit::inline_preconditions_checkIndex(BasicType bt) { | |||
|
|||
// length is now known positive, add a cast node to make this explicit | |||
jlong upper_bound = _gvn.type(length)->is_integer(bt)->hi_as_long(); | |||
Node* casted_length = ConstraintCastNode::make(control(), length, TypeInteger::make(0, upper_bound, Type::WidenMax, bt), ConstraintCastNode::RegularDependency, bt); | |||
Node *casted_length = ConstraintCastNode::make_cast_for_basic_type( |
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.
Node *casted_length = ConstraintCastNode::make_cast_for_basic_type( | |
Node* casted_length = ConstraintCastNode::make_cast_for_basic_type( |
@@ -1168,7 +1169,9 @@ bool LibraryCallKit::inline_preconditions_checkIndex(BasicType bt) { | |||
} | |||
|
|||
// index is now known to be >= 0 and < length, cast it | |||
Node* result = ConstraintCastNode::make(control(), index, TypeInteger::make(0, upper_bound, Type::WidenMax, bt), ConstraintCastNode::RegularDependency, bt); | |||
Node *result = ConstraintCastNode::make_cast_for_basic_type( |
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.
Node *result = ConstraintCastNode::make_cast_for_basic_type( | |
Node* result = ConstraintCastNode::make_cast_for_basic_type( |
@@ -3422,7 +3420,10 @@ bool IdealLoopTree::do_remove_empty_loop(PhaseIdealLoop *phase) { | |||
Node* exact_limit = phase->exact_limit(this); | |||
|
|||
// We need to pin the exact limit to prevent it from floating above the zero trip guard. | |||
Node* cast_ii = ConstraintCastNode::make(cl->in(LoopNode::EntryControl), exact_limit, phase->_igvn.type(exact_limit), ConstraintCastNode::UnconditionalDependency, T_INT); | |||
Node *cast_ii = ConstraintCastNode::make_cast_for_basic_type( |
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.
Node *cast_ii = ConstraintCastNode::make_cast_for_basic_type( | |
Node* cast_ii = ConstraintCastNode::make_cast_for_basic_type( |
src/hotspot/share/opto/castnode.hpp
Outdated
@@ -68,8 +69,7 @@ class ConstraintCastNode: public TypeNode { | |||
virtual bool depends_only_on_test() const { return _dependency == RegularDependency; } | |||
bool carry_dependency() const { return _dependency != RegularDependency; } | |||
TypeNode* dominating_cast(PhaseGVN* gvn, PhaseTransform* pt) const; | |||
static Node* make_cast(int opcode, Node* c, Node* n, const Type* t, DependencyType dependency, const TypeTuple* extra_types); | |||
static Node* make(Node* c, Node *n, const Type *t, DependencyType dependency, BasicType bt); | |||
static Node* make_cast_for_basic_type(Node* c, Node *n, const Type *t, DependencyType dependency, BasicType bt); |
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.
static Node* make_cast_for_basic_type(Node* c, Node *n, const Type *t, DependencyType dependency, BasicType bt); | |
static Node* make_cast_for_basic_type(Node* c, Node* n, const Type* t, DependencyType dependency, BasicType bt); |
/integrate |
@caojoshua |
/sponsor |
Going to push as commit 7263e25.
Your commit was automatically rebased without conflicts. |
@phohensee @caojoshua Pushed as commit 7263e25. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
It is a common pattern to have:
We can modify the constructor to set the control node. It makes the code a little tidier.
Passes tier1 locally on my Linux machine
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17162/head:pull/17162
$ git checkout pull/17162
Update a local copy of the PR:
$ git checkout pull/17162
$ git pull https://git.openjdk.org/jdk.git pull/17162/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17162
View PR using the GUI difftool:
$ git pr show -t 17162
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17162.diff
Webrev
Link to Webrev Comment