diff options
author | Florian Hahn <flo@fhahn.com> | 2024-05-28 09:23:02 -0700 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2024-05-28 09:23:02 -0700 |
commit | 234cc40adc610a55d1a5a2fe798a9dd07b993f0c (patch) | |
tree | 4bebbba33eb20033ce5792b26ecd784e93e24e0f /llvm/lib/Analysis/LoopAccessAnalysis.cpp | |
parent | 259caad2f75011174d39615bb0ba31955d16d498 (diff) | |
download | llvm-234cc40adc610a55d1a5a2fe798a9dd07b993f0c.zip llvm-234cc40adc610a55d1a5a2fe798a9dd07b993f0c.tar.gz llvm-234cc40adc610a55d1a5a2fe798a9dd07b993f0c.tar.bz2 |
[LAA] Limit no-overlap check to at least one loop-invariant accesses.
Limit the logic added in https://github.com/llvm/llvm-project/pull/9230
to cases where either sink or source are loop-invariant, to avoid
compile-time increases. This is not needed for correctness.
I am working on follow-up changes to reduce the compile-time impact in
general to allow us to enable this again for any source/sink.
This should fix the compile-time regression introduced by this change:
* compile-time improvement with this change:
https://llvm-compile-time-tracker.com/compare.php?from=4351787fb650da6d1bfb8d6e58753c90dcd4c418&to=b89010a2eb5f98494787c1c3b77f25208c59090c&stat=instructions:u
* compile-time improvement with original patch reverted on top of this
change:
https://llvm-compile-time-tracker.com/compare.php?from=b89010a2eb5f98494787c1c3b77f25208c59090c&to=19a1103fe68115cfd7d6472c6961f4fabe81a593&stat=instructions:u
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopAccessAnalysis.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index bc8b9b8..bd4c2a3 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -1983,20 +1983,25 @@ getDependenceDistanceStrideAndSize( return MemoryDepChecker::Dependence::IndirectUnsafe; // Check if we can prove that Sink only accesses memory after Src's end or - // vice versa. - const auto &[SrcStart, SrcEnd] = - getStartAndEndForAccess(InnermostLoop, Src, ATy, PSE); - const auto &[SinkStart, SinkEnd] = - getStartAndEndForAccess(InnermostLoop, Sink, BTy, PSE); - - if (!isa<SCEVCouldNotCompute>(SrcStart) && - !isa<SCEVCouldNotCompute>(SrcEnd) && - !isa<SCEVCouldNotCompute>(SinkStart) && - !isa<SCEVCouldNotCompute>(SinkEnd)) { - if (SE.isKnownPredicate(CmpInst::ICMP_ULE, SrcEnd, SinkStart)) - return MemoryDepChecker::Dependence::NoDep; - if (SE.isKnownPredicate(CmpInst::ICMP_ULE, SinkEnd, SrcStart)) - return MemoryDepChecker::Dependence::NoDep; + // vice versa. At the moment this is limited to cases where either source or + // sink are loop invariant to avoid compile-time increases. This is not + // required for correctness. + if (SE.isLoopInvariant(Src, InnermostLoop) || + SE.isLoopInvariant(Sink, InnermostLoop)) { + const auto &[SrcStart, SrcEnd] = + getStartAndEndForAccess(InnermostLoop, Src, ATy, PSE); + const auto &[SinkStart, SinkEnd] = + getStartAndEndForAccess(InnermostLoop, Sink, BTy, PSE); + + if (!isa<SCEVCouldNotCompute>(SrcStart) && + !isa<SCEVCouldNotCompute>(SrcEnd) && + !isa<SCEVCouldNotCompute>(SinkStart) && + !isa<SCEVCouldNotCompute>(SinkEnd)) { + if (SE.isKnownPredicate(CmpInst::ICMP_ULE, SrcEnd, SinkStart)) + return MemoryDepChecker::Dependence::NoDep; + if (SE.isKnownPredicate(CmpInst::ICMP_ULE, SinkEnd, SrcStart)) + return MemoryDepChecker::Dependence::NoDep; + } } // Need accesses with constant strides and the same direction. We don't want |