[llvm] [LAA] Support different strides & non constant dep distances using SCEV. (PR #88039)
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 25 06:21:12 PDT 2024
================
@@ -2071,34 +2092,51 @@ MemoryDepChecker::Dependence::DepType MemoryDepChecker::isDependent(
// NOTE: There is no need to update MaxSafeVectorWidthInBits after call to
// couldPreventStoreLoadForward, even if it changed MinDepDistBytes, since a
// forward dependency will allow vectorization using any width.
- if (IsTrueDataDependence && EnableForwardingConflictDetection &&
- (!HasSameSize || couldPreventStoreLoadForward(Val.abs().getZExtValue(),
- TypeByteSize))) {
- LLVM_DEBUG(dbgs() << "LAA: Forward but may prevent st->ld forwarding\n");
- return Dependence::ForwardButPreventsForwarding;
+ if (IsTrueDataDependence && EnableForwardingConflictDetection) {
+ if (!C) {
+ // TODO: Relax requirement that there is a common stride to retry with
+ // non-constant distance dependencies.
+ FoundNonConstantDistanceDependence |= !!CommonStride;
+ return Dependence::Unknown;
+ }
+ if (!HasSameSize ||
+ couldPreventStoreLoadForward(C->getAPInt().abs().getZExtValue(),
+ TypeByteSize)) {
+ LLVM_DEBUG(
+ dbgs() << "LAA: Forward but may prevent st->ld forwarding\n");
+ return Dependence::ForwardButPreventsForwarding;
+ }
}
LLVM_DEBUG(dbgs() << "LAA: Dependence is negative\n");
return Dependence::Forward;
}
- // Write to the same location with the same size.
- if (Val == 0) {
- if (HasSameSize)
- return Dependence::Forward;
- LLVM_DEBUG(
- dbgs() << "LAA: Zero dependence difference but different type sizes\n");
+ if (!C) {
+ // 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 non-constant distance\n");
----------------
Meinersbur wrote:
Not that I like the arbitrary-looking `!!CommonStride` scattered around the code, but at least I understand now. `FoundNonConstantDistanceDependence` sounded like something that's safer to set to true when in doubt. Should really be called `ReconsiderWithRuntimeChecks`. If I may suggest an alternative TODO:
```
// TODO: FoundNonConstantDistanceDependence is used as a necessary condition to consider retrying
// with runtime checks. Historically, we did not set it when strides were different but there is no inherent
// reason to.
```
https://github.com/llvm/llvm-project/pull/88039
More information about the llvm-commits
mailing list