From 8052e94946ec7535f2d22aae1dbf3c48d3cd1b34 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 18 Jun 2024 16:43:19 +0200 Subject: [InstCombine] Avoid use of ConstantExpr::getShl() Use the constant folding API instead. Use ImmConstant to make sure it actually folds. --- llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp index 244f099..5e3f659 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp @@ -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; -- cgit v1.1