[llvm] 5aaf2ab - [Reassociate] Avoid use of ConstantExpr::getShl()
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 18 08:00:17 PDT 2024
Author: Nikita Popov
Date: 2024-06-18T16:59:51+02:00
New Revision: 5aaf2ab085ef85498a65a1af03a1b3812c2cf531
URL: https://github.com/llvm/llvm-project/commit/5aaf2ab085ef85498a65a1af03a1b3812c2cf531
DIFF: https://github.com/llvm/llvm-project/commit/5aaf2ab085ef85498a65a1af03a1b3812c2cf531.diff
LOG: [Reassociate] Avoid use of ConstantExpr::getShl()
Use the constant folding API instead.
Added:
Modified:
llvm/lib/Transforms/Scalar/Reassociate.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/Reassociate.cpp b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index 93d539efa16e7..c84107d7ef2cb 100644
--- a/llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -1022,7 +1022,8 @@ static BinaryOperator *BreakUpSubtract(Instruction *Sub,
static BinaryOperator *ConvertShiftToMul(Instruction *Shl) {
Constant *MulCst = ConstantInt::get(Shl->getType(), 1);
auto *SA = cast<ConstantInt>(Shl->getOperand(1));
- MulCst = ConstantExpr::getShl(MulCst, SA);
+ MulCst = ConstantFoldBinaryInstruction(Instruction::Shl, MulCst, SA);
+ assert(MulCst && "Constant folding of immediate constants failed");
BinaryOperator *Mul = BinaryOperator::CreateMul(Shl->getOperand(0), MulCst,
"", Shl->getIterator());
More information about the llvm-commits
mailing list