Skip to content

Commit e4da0a1

Browse files
authored
JIT: Fix bad constant folding of (0 shift x) => x (#113493)
1 parent 229f6ac commit e4da0a1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/coreclr/jit/lower.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -7810,10 +7810,10 @@ bool Lowering::TryFoldBinop(GenTreeOp* node)
78107810
return true;
78117811
}
78127812

7813-
if (node->OperIs(GT_LSH, GT_RSH, GT_RSZ, GT_ROL, GT_ROR, GT_OR, GT_XOR) &&
7814-
(op1->IsIntegralConst(0) || op2->IsIntegralConst(0)))
7813+
if ((node->OperIs(GT_LSH, GT_RSH, GT_RSZ, GT_ROL, GT_ROR) && op2->IsIntegralConst(0)) ||
7814+
(node->OperIs(GT_OR, GT_XOR) && (op1->IsIntegralConst(0) || op2->IsIntegralConst(0))))
78157815
{
7816-
GenTree* zeroOp = op1->IsIntegralConst(0) ? op1 : op2;
7816+
GenTree* zeroOp = op2->IsIntegralConst(0) ? op2 : op1;
78177817
GenTree* otherOp = zeroOp == op1 ? op2 : op1;
78187818

78197819
LIR::Use use;

0 commit comments

Comments
 (0)