Skip to content

Commit 8052e94

Browse files
committed
[InstCombine] Avoid use of ConstantExpr::getShl()
Use the constant folding API instead. Use ImmConstant to make sure it actually folds.
1 parent e64ed1d commit 8052e94

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2063,8 +2063,10 @@ static BinopElts getAlternateBinop(BinaryOperator *BO, const DataLayout &DL) {
20632063
case Instruction::Shl: {
20642064
// shl X, C --> mul X, (1 << C)
20652065
Constant *C;
2066-
if (match(BO1, m_Constant(C))) {
2067-
Constant *ShlOne = ConstantExpr::getShl(ConstantInt::get(Ty, 1), C);
2066+
if (match(BO1, m_ImmConstant(C))) {
2067+
Constant *ShlOne = ConstantFoldBinaryOpOperands(
2068+
Instruction::Shl, ConstantInt::get(Ty, 1), C, DL);
2069+
assert(ShlOne && "Constant folding of immediate constants failed");
20682070
return {Instruction::Mul, BO0, ShlOne};
20692071
}
20702072
break;

0 commit comments

Comments
 (0)