Skip to content

Commit 756d22c

Browse files
committed
8274130: C2: MulNode::Ideal chained transformations may act on wrong nodes
Reviewed-by: thartmann, kvn
1 parent 5b0c9cc commit 756d22c

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/hotspot/share/opto/mulnode.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ Node* MulNode::Identity(PhaseGVN* phase) {
5959
// We also canonicalize the Node, moving constants to the right input,
6060
// and flatten expressions (so that 1+x+2 becomes x+3).
6161
Node *MulNode::Ideal(PhaseGVN *phase, bool can_reshape) {
62-
const Type *t1 = phase->type( in(1) );
63-
const Type *t2 = phase->type( in(2) );
64-
Node *progress = NULL; // Progress flag
62+
Node* in1 = in(1);
63+
Node* in2 = in(2);
64+
Node* progress = NULL; // Progress flag
6565

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

7272
// Convert "(-a)*(-b)" into "a*b".
73-
Node *in1 = in(1);
74-
Node *in2 = in(2);
7573
if (real_mul && in1->is_Sub() && in2->is_Sub()) {
7674
if (phase->type(in1->in(1))->is_zero_type() &&
7775
phase->type(in2->in(1))->is_zero_type()) {
@@ -82,6 +80,8 @@ Node *MulNode::Ideal(PhaseGVN *phase, bool can_reshape) {
8280
igvn->_worklist.push(in1);
8381
igvn->_worklist.push(in2);
8482
}
83+
in1 = in(1);
84+
in2 = in(2);
8585
progress = this;
8686
}
8787
}
@@ -104,10 +104,15 @@ Node *MulNode::Ideal(PhaseGVN *phase, bool can_reshape) {
104104
igvn->_worklist.push(in1);
105105
igvn->_worklist.push(in2);
106106
}
107+
in1 = in(1);
108+
in2 = in(2);
107109
progress = this;
108110
}
109111
}
110112

113+
const Type* t1 = phase->type(in1);
114+
const Type* t2 = phase->type(in2);
115+
111116
// We are OK if right is a constant, or right is a load and
112117
// left is a non-constant.
113118
if( !(t2->singleton() ||

0 commit comments

Comments
 (0)