[llvm] 7660981 - [LSR] Use computeConstantDifference()
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 28 03:21:25 PDT 2024
Author: Nikita Popov
Date: 2024-08-28T12:20:59+02:00
New Revision: 7660981402bccaad0e351a65913ebd37436e4816
URL: https://github.com/llvm/llvm-project/commit/7660981402bccaad0e351a65913ebd37436e4816
DIFF: https://github.com/llvm/llvm-project/commit/7660981402bccaad0e351a65913ebd37436e4816.diff
LOG: [LSR] Use computeConstantDifference()
This API is faster than getMinusSCEV() and a SCEVConstant cast.
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index a62b87fe2a53d4..3ca3818938fd26 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -5304,17 +5304,17 @@ static bool IsSimplerBaseSCEVForTarget(const TargetTransformInfo &TTI,
cast<SCEVAddRecExpr>(Best)->getLoop() !=
cast<SCEVAddRecExpr>(Reg)->getLoop()))
return false;
- const auto *Diff = dyn_cast<SCEVConstant>(SE.getMinusSCEV(Best, Reg));
+ std::optional<APInt> Diff = SE.computeConstantDifference(Best, Reg);
if (!Diff)
return false;
return TTI.isLegalAddressingMode(
AccessType.MemTy, /*BaseGV=*/nullptr,
- /*BaseOffset=*/Diff->getAPInt().getSExtValue(),
+ /*BaseOffset=*/Diff->getSExtValue(),
/*HasBaseReg=*/true, /*Scale=*/0, AccessType.AddrSpace) &&
!TTI.isLegalAddressingMode(
AccessType.MemTy, /*BaseGV=*/nullptr,
- /*BaseOffset=*/-Diff->getAPInt().getSExtValue(),
+ /*BaseOffset=*/-Diff->getSExtValue(),
/*HasBaseReg=*/true, /*Scale=*/0, AccessType.AddrSpace);
}
More information about the llvm-commits
mailing list