diff options
author | Serguei Katkov <serguei.katkov@azul.com> | 2022-02-17 12:06:23 +0700 |
---|---|---|
committer | Serguei Katkov <serguei.katkov@azul.com> | 2022-02-18 12:40:26 +0700 |
commit | b45d0b3e8e003291f99a12d039c8a54a064adfcb (patch) | |
tree | 7f13f90ecc6bc72476e38cc4295e1e3c0d313c41 /llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | |
parent | 2ad662172cbbd1ca53489bf8bddb0183d7692708 (diff) | |
download | llvm-b45d0b3e8e003291f99a12d039c8a54a064adfcb.zip llvm-b45d0b3e8e003291f99a12d039c8a54a064adfcb.tar.gz llvm-b45d0b3e8e003291f99a12d039c8a54a064adfcb.tar.bz2 |
[MemoryDependency] Simplfy re-ordering condition. Cleanup. NFC.
Make the reading of condition for restricting re-ordering simpler.
Reviewers: reames
Reviewed By: reames
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D120005
Diffstat (limited to 'llvm/lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 39 |
1 files changed, 13 insertions, 26 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index aaeba90..923fcdc 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -414,30 +414,17 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom( isInvariantLoad = true; } - // Return "true" if and only if the instruction I is either a non-simple - // load or a non-simple store. - auto isNonSimpleLoadOrStore = [](Instruction *I) -> bool { + // True for volatile instruction. + // For Load/Store return true if atomic ordering is stronger than AO, + // for other instruction just true if it can read or write to memory. + auto isComplexForReordering = [](Instruction * I, AtomicOrdering AO)->bool { + if (I->isVolatile()) + return true; if (auto *LI = dyn_cast<LoadInst>(I)) - return !LI->isSimple(); + return isStrongerThan(LI->getOrdering(), AO); if (auto *SI = dyn_cast<StoreInst>(I)) - return !SI->isSimple(); - return false; - }; - - // Return "true" if and only if the instruction I is either a non-unordered - // load or a non-unordered store. - auto isNonUnorderedLoadOrStore = [](Instruction *I) -> bool { - if (auto *LI = dyn_cast<LoadInst>(I)) - return !LI->isUnordered(); - if (auto *SI = dyn_cast<StoreInst>(I)) - return !SI->isUnordered(); - return false; - }; - - // Return "true" if I is not a load and not a store, but it does access - // memory. - auto isOtherMemAccess = [](Instruction *I) -> bool { - return !isa<LoadInst>(I) && !isa<StoreInst>(I) && I->mayReadOrWriteMemory(); + return isStrongerThan(SI->getOrdering(), AO); + return I->mayReadOrWriteMemory(); }; // Walk backwards through the basic block, looking for dependencies. @@ -510,8 +497,8 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom( // atomic. // FIXME: This is overly conservative. if (LI->isAtomic() && isStrongerThanUnordered(LI->getOrdering())) { - if (!QueryInst || isNonSimpleLoadOrStore(QueryInst) || - isOtherMemAccess(QueryInst)) + if (!QueryInst || + isComplexForReordering(QueryInst, AtomicOrdering::NotAtomic)) return MemDepResult::getClobber(LI); if (LI->getOrdering() != AtomicOrdering::Monotonic) return MemDepResult::getClobber(LI); @@ -559,8 +546,8 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom( // A Monotonic store is OK if the query inst is itself not atomic. // FIXME: This is overly conservative. if (!SI->isUnordered() && SI->isAtomic()) { - if (!QueryInst || isNonUnorderedLoadOrStore(QueryInst) || - isOtherMemAccess(QueryInst)) + if (!QueryInst || + isComplexForReordering(QueryInst, AtomicOrdering::Unordered)) return MemDepResult::getClobber(SI); // Ok, if we are here the guard above guarantee us that // QueryInst is a non-atomic or unordered load/store. |