aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2024-06-18 16:43:19 +0200
committerNikita Popov <npopov@redhat.com>2024-06-18 16:43:19 +0200
commit8052e94946ec7535f2d22aae1dbf3c48d3cd1b34 (patch)
tree7001ceebd8fbe59f8acf5117dc231e4a2bfb9e26
parente64ed1db46967fe9963751873b5d0098b57c9316 (diff)
downloadllvm-8052e94946ec7535f2d22aae1dbf3c48d3cd1b34.zip
llvm-8052e94946ec7535f2d22aae1dbf3c48d3cd1b34.tar.gz
llvm-8052e94946ec7535f2d22aae1dbf3c48d3cd1b34.tar.bz2
[InstCombine] Avoid use of ConstantExpr::getShl()
Use the constant folding API instead. Use ImmConstant to make sure it actually folds.
-rw-r--r--llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp6
1 files 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;