Skip to content

Commit

Permalink
[InstCombine] Avoid use of ConstantExpr::getShl()
Browse files Browse the repository at this point in the history
Use the constant folding API instead. Use ImmConstant to make
sure it actually folds.
  • Loading branch information
nikic committed Jun 18, 2024
1 parent e64ed1d commit 8052e94
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2063,8 +2063,10 @@ static BinopElts getAlternateBinop(BinaryOperator *BO, const DataLayout &DL) {
case Instruction::Shl: {
// shl X, C --> mul X, (1 << C)
Constant *C;
if (match(BO1, m_Constant(C))) {
Constant *ShlOne = ConstantExpr::getShl(ConstantInt::get(Ty, 1), C);
if (match(BO1, m_ImmConstant(C))) {
Constant *ShlOne = ConstantFoldBinaryOpOperands(
Instruction::Shl, ConstantInt::get(Ty, 1), C, DL);
assert(ShlOne && "Constant folding of immediate constants failed");
return {Instruction::Mul, BO0, ShlOne};
}
break;
Expand Down

0 comments on commit 8052e94

Please sign in to comment.