From: Philip Reames Date: Mon, 1 May 2023 15:32:28 +0000 (-0700) Subject: [LAA] Use early return [nfc] X-Git-Tag: upstream/17.0.6~9900 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=89a44b0faee0ca6b741e1f0ef31163374887b6ed;p=platform%2Fupstream%2Fllvm.git [LAA] Use early return [nfc] --- 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 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 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;