[llvm] 2124b2f - [JumpThreading] Avoid ConstantExpr::get() (NFCI)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 29 07:43:12 PDT 2022
Author: Nikita Popov
Date: 2022-06-29T16:43:05+02:00
New Revision: 2124b2f0e6083470cf27448e4217706ee646ab03
URL: https://github.com/llvm/llvm-project/commit/2124b2f0e6083470cf27448e4217706ee646ab03
DIFF: https://github.com/llvm/llvm-project/commit/2124b2f0e6083470cf27448e4217706ee646ab03.diff
LOG: [JumpThreading] Avoid ConstantExpr::get() (NFCI)
This code requires the result to be an UndefValue/ConstantInt
anyway (checked by getKnownConstant), so we are only interested
in the case where this folds.
Added:
Modified:
llvm/lib/Transforms/Scalar/JumpThreading.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
index 8b0b638228b7f..ee7ef1ed4a3ca 100644
--- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp
@@ -788,6 +788,7 @@ bool JumpThreadingPass::computeValueKnownInPredecessorsImpl(
if (Preference != WantInteger)
return false;
if (ConstantInt *CI = dyn_cast<ConstantInt>(BO->getOperand(1))) {
+ const DataLayout &DL = BO->getModule()->getDataLayout();
PredValueInfoTy LHSVals;
computeValueKnownInPredecessorsImpl(BO->getOperand(0), BB, LHSVals,
WantInteger, RecursionSet, CxtI);
@@ -795,7 +796,8 @@ bool JumpThreadingPass::computeValueKnownInPredecessorsImpl(
// Try to use constant folding to simplify the binary operator.
for (const auto &LHSVal : LHSVals) {
Constant *V = LHSVal.first;
- Constant *Folded = ConstantExpr::get(BO->getOpcode(), V, CI);
+ Constant *Folded =
+ ConstantFoldBinaryOpOperands(BO->getOpcode(), V, CI, DL);
if (Constant *KC = getKnownConstant(Folded, WantInteger))
Result.emplace_back(KC, LHSVal.second);
More information about the llvm-commits
mailing list