8274130: C2: MulNode::Ideal chained transformations may act on wrong nodes

Reviewed-by: thartmann, kvn
This commit is contained in:
Aleksey Shipilev 2021-09-29 05:41:34 +00:00
parent 5b0c9ccc49
commit 756d22c356

View File

@ -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.
@ -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()) {
@ -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;
}
}
@ -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() ||