Skip to content
Closed
Changes from all commits
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
18 changes: 18 additions & 0 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12687,6 +12687,24 @@ GenTree* Compiler::fgOptimizeMultiply(GenTreeOp* mul)
fgUpdateConstTreeValueNumber(op2);
mul->ChangeOper(GT_LSH, GenTree::PRESERVE_VN);

if (mul->gtGetOp1()->OperIs(GT_LSH) && mul->gtGetOp1()->gtGetOp2()->IsIntegralConst())
{
GenTree* lsOp = mul->gtGetOp1();
GenTree* rsOp = mul->gtGetOp2();
GenTree* lsOpChOp1 = lsOp->gtGetOp1();
GenTree* lsOpChOp2 = lsOp->gtGetOp2();

int64_t child_val = lsOpChOp2->AsIntConCommon()->IntegralValue();
int64_t root_val = rsOp->AsIntConCommon()->IntegralValue();

mul->gtOp1 = lsOpChOp1;
mul->gtOp2 = lsOpChOp2;
mul->gtOp2->AsIntConCommon()->SetIntegralValue(root_val + child_val);

DEBUG_DESTROY_NODE(lsOp);
DEBUG_DESTROY_NODE(rsOp);
}

return mul;
}
}
Expand Down