diff options
author | Philip Reames <preames@rivosinc.com> | 2023-05-01 08:32:28 -0700 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2023-05-01 08:35:56 -0700 |
commit | 89a44b0faee0ca6b741e1f0ef31163374887b6ed (patch) | |
tree | 226d45de67138586ebb301428a495ed00a8c2f96 /llvm/lib/Analysis/LoopAccessAnalysis.cpp | |
parent | 6cd3343b4a382c02df95a38f301b4831899bd230 (diff) | |
download | llvm-89a44b0faee0ca6b741e1f0ef31163374887b6ed.zip llvm-89a44b0faee0ca6b741e1f0ef31163374887b6ed.tar.gz llvm-89a44b0faee0ca6b741e1f0ef31163374887b6ed.tar.bz2 |
[LAA] Use early return [nfc]
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopAccessAnalysis.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 4420d72..2707d0e 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; |