[llvm] 89a44b0 - [LAA] Use early return [nfc]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon May 1 08:36:07 PDT 2023
Author: Philip Reames
Date: 2023-05-01T08:35:56-07:00
New Revision: 89a44b0faee0ca6b741e1f0ef31163374887b6ed
URL: https://github.com/llvm/llvm-project/commit/89a44b0faee0ca6b741e1f0ef31163374887b6ed
DIFF: https://github.com/llvm/llvm-project/commit/89a44b0faee0ca6b741e1f0ef31163374887b6ed.diff
LOG: [LAA] Use early return [nfc]
Added:
Modified:
llvm/lib/Analysis/LoopAccessAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index 4420d729e2883..2707d0ec572f1 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1414,19 +1414,19 @@ std::optional<int64_t> llvm::getPtrStride(PredicatedScalarEvolution &PSE,
isNoWrapAddRec(Ptr, AR, PSE, Lp);
if (!IsNoWrapAddRec && !IsInBoundsGEP &&
NullPointerIsDefined(Lp->getHeader()->getParent(), AddrSpace)) {
- if (Assume) {
- PSE.setNoOverflow(Ptr, SCEVWrapPredicate::IncrementNUSW);
- IsNoWrapAddRec = true;
- LLVM_DEBUG(dbgs() << "LAA: Pointer may wrap in the address space:\n"
- << "LAA: Pointer: " << *Ptr << "\n"
- << "LAA: SCEV: " << *AR << "\n"
- << "LAA: Added an overflow assumption\n");
- } else {
+ if (!Assume) {
LLVM_DEBUG(
dbgs() << "LAA: Bad stride - Pointer may wrap in the address space "
<< *Ptr << " SCEV: " << *AR << "\n");
return std::nullopt;
}
+
+ PSE.setNoOverflow(Ptr, SCEVWrapPredicate::IncrementNUSW);
+ IsNoWrapAddRec = true;
+ LLVM_DEBUG(dbgs() << "LAA: Pointer may wrap in the address space:\n"
+ << "LAA: Pointer: " << *Ptr << "\n"
+ << "LAA: SCEV: " << *AR << "\n"
+ << "LAA: Added an overflow assumption\n");
}
// Check the step is constant.
@@ -1463,16 +1463,16 @@ std::optional<int64_t> llvm::getPtrStride(PredicatedScalarEvolution &PSE,
if (!IsNoWrapAddRec && Stride != 1 && Stride != -1 &&
(IsInBoundsGEP || !NullPointerIsDefined(Lp->getHeader()->getParent(),
AddrSpace))) {
- if (Assume) {
- // We can avoid this case by adding a run-time check.
- LLVM_DEBUG(dbgs() << "LAA: Non unit strided pointer which is not either "
- << "inbounds or in address space 0 may wrap:\n"
- << "LAA: Pointer: " << *Ptr << "\n"
- << "LAA: SCEV: " << *AR << "\n"
- << "LAA: Added an overflow assumption\n");
- PSE.setNoOverflow(Ptr, SCEVWrapPredicate::IncrementNUSW);
- } else
+ if (!Assume)
return std::nullopt;
+
+ // We can avoid this case by adding a run-time check.
+ LLVM_DEBUG(dbgs() << "LAA: Non unit strided pointer which is not either "
+ << "inbounds or in address space 0 may wrap:\n"
+ << "LAA: Pointer: " << *Ptr << "\n"
+ << "LAA: SCEV: " << *AR << "\n"
+ << "LAA: Added an overflow assumption\n");
+ PSE.setNoOverflow(Ptr, SCEVWrapPredicate::IncrementNUSW);
}
return Stride;
More information about the llvm-commits
mailing list