Skip to content

Commit 5aaf2ab

Browse files
committed
[Reassociate] Avoid use of ConstantExpr::getShl()
Use the constant folding API instead.
1 parent 534e3ad commit 5aaf2ab

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Transforms/Scalar/Reassociate.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,8 @@ static BinaryOperator *BreakUpSubtract(Instruction *Sub,
10221022
static BinaryOperator *ConvertShiftToMul(Instruction *Shl) {
10231023
Constant *MulCst = ConstantInt::get(Shl->getType(), 1);
10241024
auto *SA = cast<ConstantInt>(Shl->getOperand(1));
1025-
MulCst = ConstantExpr::getShl(MulCst, SA);
1025+
MulCst = ConstantFoldBinaryInstruction(Instruction::Shl, MulCst, SA);
1026+
assert(MulCst && "Constant folding of immediate constants failed");
10261027

10271028
BinaryOperator *Mul = BinaryOperator::CreateMul(Shl->getOperand(0), MulCst,
10281029
"", Shl->getIterator());

0 commit comments

Comments
 (0)