[llvm] [LAA] Support different strides & non constant dep distances using SCEV. (PR #88039)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 16 05:47:16 PDT 2024
================
@@ -2028,68 +2029,105 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
if (std::holds_alternative<Dependence::DepType>(Res))
return std::get<Dependence::DepType>(Res);
- const auto &[Dist, Stride, TypeByteSize, AIsWrite, BIsWrite] =
+ const auto &[Dist, StrideA, StrideB, TypeByteSize, AIsWrite, BIsWrite] =
std::get<DepDistanceStrideAndSizeInfo>(Res);
bool HasSameSize = TypeByteSize > 0;
+ uint64_t CommonStride = StrideA == StrideB ? StrideA : 0;
+ if (isa<SCEVCouldNotCompute>(Dist)) {
+ FoundNonConstantDistanceDependence |= CommonStride;
+ LLVM_DEBUG(dbgs() << "LAA: Dependence because of uncomputable distance.\n");
+ return Dependence::Unknown;
+ }
+
ScalarEvolution &SE = *PSE.getSE();
auto &DL = InnermostLoop->getHeader()->getModule()->getDataLayout();
- if (!isa<SCEVCouldNotCompute>(Dist) && HasSameSize &&
+ if (HasSameSize && CommonStride &&
isSafeDependenceDistance(DL, SE, *(PSE.getBackedgeTakenCount()), *Dist,
- Stride, TypeByteSize))
+ CommonStride, TypeByteSize))
----------------
Meinersbur wrote:
`isSafeDependenceDistance` doesn't depend on there being a common stride. It could either be the larger one, or a case-distinction of either Dist positive (Src < Sink) or positive (Sink < Src).
https://github.com/llvm/llvm-project/pull/88039
More information about the llvm-commits
mailing list