[llvm-branch-commits] [llvm] [LAA] Support different strides & non constant dep distances using SCEV. (PR #88039)
Michael Kruse via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Apr 22 05:33:59 PDT 2024
================
@@ -2028,41 +2029,61 @@ 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;
+ std::optional<uint64_t> CommonStride =
+ StrideA == StrideB ? std::make_optional(StrideA) : std::nullopt;
+ if (isa<SCEVCouldNotCompute>(Dist)) {
+ // TODO: Relax requirement that there is a common stride to retry with
+ // non-constant distance dependencies.
+ 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 the distance between the acecsses is larger than their absolute stride
// multiplied by the backedge taken count, the accesses are independet, i.e.
// they are far enough appart that accesses won't access the same location
// across all loop ierations.
- if (!isa<SCEVCouldNotCompute>(Dist) && HasSameSize &&
+ if (HasSameSize && CommonStride &&
----------------
Meinersbur wrote:
`isSafeDependenceDistance` could be easily modified as well to support different sizes, but it's unrelated to this patch.
https://github.com/llvm/llvm-project/pull/88039
More information about the llvm-branch-commits
mailing list