Skip to content

Commit

Permalink
8274130: C2: MulNode::Ideal chained transformations may act on wrong …
Browse files Browse the repository at this point in the history
…nodes

Reviewed-by: thartmann, kvn
  • Loading branch information
shipilev committed Sep 29, 2021
1 parent 5b0c9cc commit 756d22c
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/hotspot/share/opto/mulnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ Node* MulNode::Identity(PhaseGVN* phase) {
// We also canonicalize the Node, moving constants to the right input,
// and flatten expressions (so that 1+x+2 becomes x+3).
Node *MulNode::Ideal(PhaseGVN *phase, bool can_reshape) {
const Type *t1 = phase->type( in(1) );
const Type *t2 = phase->type( in(2) );
Node *progress = NULL; // Progress flag
Node* in1 = in(1);
Node* in2 = in(2);
Node* progress = NULL; // Progress flag

// This code is used by And nodes too, but some conversions are
// only valid for the actual Mul nodes.
Expand All @@ -70,8 +70,6 @@ Node *MulNode::Ideal(PhaseGVN *phase, bool can_reshape) {
(op == Op_MulF) || (op == Op_MulD);

// Convert "(-a)*(-b)" into "a*b".
Node *in1 = in(1);
Node *in2 = in(2);
if (real_mul && in1->is_Sub() && in2->is_Sub()) {
if (phase->type(in1->in(1))->is_zero_type() &&
phase->type(in2->in(1))->is_zero_type()) {
Expand All @@ -82,6 +80,8 @@ Node *MulNode::Ideal(PhaseGVN *phase, bool can_reshape) {
igvn->_worklist.push(in1);
igvn->_worklist.push(in2);
}
in1 = in(1);
in2 = in(2);
progress = this;
}
}
Expand All @@ -104,10 +104,15 @@ Node *MulNode::Ideal(PhaseGVN *phase, bool can_reshape) {
igvn->_worklist.push(in1);
igvn->_worklist.push(in2);
}
in1 = in(1);
in2 = in(2);
progress = this;
}
}

const Type* t1 = phase->type(in1);
const Type* t2 = phase->type(in2);

// We are OK if right is a constant, or right is a load and
// left is a non-constant.
if( !(t2->singleton() ||
Expand Down

1 comment on commit 756d22c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.