Skip to content
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

8332827: [REDO] C2: crash in compiled code because of dependency on removed range check CastIIs #22568

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
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
5 changes: 5 additions & 0 deletions src/hotspot/share/opto/compile.cpp
Original file line number Diff line number Diff line change
@@ -3143,6 +3143,11 @@ void Compile::handle_div_mod_op(Node* n, BasicType bt, bool is_unsigned) {
// Replace them with a fused divmod if supported
if (Matcher::has_match_rule(Op_DivModIL(bt, is_unsigned))) {
DivModNode* divmod = DivModNode::make(n, bt, is_unsigned);
// If the divisor input for a Div (or Mod etc.) is not null, then the control input of the Div is set to null.
// It could be that the divisor input is found not null because its type is narrowed down by a CastII in the
Copy link
Member

Choose a reason for hiding this comment

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

You mean not zero?

Suggested change
// If the divisor input for a Div (or Mod etc.) is not null, then the control input of the Div is set to null.
// It could be that the divisor input is found not null because its type is narrowed down by a CastII in the
// If the divisor input for a Div (or Mod etc.) is not zero, then the control input of the Div is set to null.
// It could be that the divisor input is found not zero because its type is narrowed down by a CastII in the

// subgraph for that input. Range check CastIIs are removed during final graph reshape. To preserve the dependency
// carried by a CastII, precedence edges are added to the Div node. We need to transfer the precedence edges to the
// DivMod node so the dependency is not lost.
divmod->add_prec_from(n);
divmod->add_prec_from(d);
d->subsume_by(divmod->div_proj(), this);