aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LoopAccessAnalysis.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2024-05-14 19:47:24 +0100
committerFlorian Hahn <flo@fhahn.com>2024-05-14 19:47:24 +0100
commit179efe5abc745b5646efeb33fef86c55aa4fd7dc (patch)
treeb24009dc0b9d8a456b27b45fb4c452d35208e0a7 /llvm/lib/Analysis/LoopAccessAnalysis.cpp
parent5adfcb07501f1d128e6517e60d30f2e3a0dc8eaa (diff)
downloadllvm-179efe5abc745b5646efeb33fef86c55aa4fd7dc.zip
llvm-179efe5abc745b5646efeb33fef86c55aa4fd7dc.tar.gz
llvm-179efe5abc745b5646efeb33fef86c55aa4fd7dc.tar.bz2
[LAA] Delay applying loop guards until after isSafeDependenceDistance.
Applying the loop guards to the distance may prevent isSafeDependenceDistance from determining NoDep, unless loop guards are also applied to the backedge-taken-count. Instead of applying the guards to both Dist and the backedge-taken-count, just apply them after handling isSafeDependenceDistance and constant distances; there is no benefit to applying the guards before then. This fixes a regression flagged by @bjope due to ecae3ed958481cba7d60868cf3504292f7f4fdf5.
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index e92aa02..4ba2e15 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1991,9 +1991,6 @@ getDependenceDistanceStrideAndSize(
return MemoryDepChecker::Dependence::Unknown;
}
- if (!isa<SCEVConstant, SCEVCouldNotCompute>(Dist))
- Dist = SE.applyLoopGuards(Dist, InnermostLoop);
-
uint64_t TypeByteSize = DL.getTypeAllocSize(ATy);
bool HasSameSize =
DL.getTypeStoreSizeInBits(ATy) == DL.getTypeStoreSizeInBits(BTy);
@@ -2019,7 +2016,7 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
if (std::holds_alternative<Dependence::DepType>(Res))
return std::get<Dependence::DepType>(Res);
- const auto &[Dist, StrideA, StrideB, TypeByteSize, AIsWrite, BIsWrite] =
+ auto &[Dist, StrideA, StrideB, TypeByteSize, AIsWrite, BIsWrite] =
std::get<DepDistanceStrideAndSizeInfo>(Res);
bool HasSameSize = TypeByteSize > 0;
@@ -2062,7 +2059,8 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
LLVM_DEBUG(dbgs() << "LAA: Strided accesses are independent\n");
return Dependence::NoDep;
}
- }
+ } else
+ Dist = SE.applyLoopGuards(Dist, InnermostLoop);
// Negative distances are not plausible dependencies.
if (SE.isKnownNonPositive(Dist)) {