[llvm] 32a76fc - [SCEVExpander] Avoid ConstantExpr::get() (NFCI)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 4 05:59:07 PDT 2022
Author: Nikita Popov
Date: 2022-07-04T14:59:00+02:00
New Revision: 32a76fc292d991408dc7276c75d35590799b2132
URL: https://github.com/llvm/llvm-project/commit/32a76fc292d991408dc7276c75d35590799b2132
DIFF: https://github.com/llvm/llvm-project/commit/32a76fc292d991408dc7276c75d35590799b2132.diff
LOG: [SCEVExpander] Avoid ConstantExpr::get() (NFCI)
Use ConstantFoldBinaryOpOperands() instead. This will be important
when not all binops have constant expression variants.
Added:
Modified:
llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
index 401f1ee5a55d..0c8bf3827256 100644
--- a/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ b/llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -220,7 +220,8 @@ Value *SCEVExpander::InsertBinop(Instruction::BinaryOps Opcode,
// Fold a binop with constant operands.
if (Constant *CLHS = dyn_cast<Constant>(LHS))
if (Constant *CRHS = dyn_cast<Constant>(RHS))
- return ConstantExpr::get(Opcode, CLHS, CRHS);
+ if (Constant *Res = ConstantFoldBinaryOpOperands(Opcode, CLHS, CRHS, DL))
+ return Res;
// Do a quick scan to see if we have this binop nearby. If so, reuse it.
unsigned ScanLimit = 6;
More information about the llvm-commits
mailing list