From 3410689a6f2da37ee24bd690b96528f072978e33 Mon Sep 17 00:00:00 2001 From: Adam Nemet Date: Tue, 3 Nov 2015 23:50:03 +0000 Subject: [PATCH] [LAA] LLE 5/6: Add predicate functions Dependence::isForward/isBackward, NFC Summary: Will be used by the LoopLoadElimination pass. Reviewers: hfinkel Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D13258 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252016 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/LoopAccessAnalysis.h | 7 ++++++- lib/Analysis/LoopAccessAnalysis.cpp | 24 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/llvm/Analysis/LoopAccessAnalysis.h b/include/llvm/Analysis/LoopAccessAnalysis.h index 35f83f1008c..f864fd1de30 100644 --- a/include/llvm/Analysis/LoopAccessAnalysis.h +++ b/include/llvm/Analysis/LoopAccessAnalysis.h @@ -179,7 +179,12 @@ public: /// \brief Dependence types that don't prevent vectorization. static bool isSafeForVectorization(DepType Type); - /// \brief Lexically backward dependence types. + /// \brief Lexically forward dependence. + bool isForward() const; + /// \brief Lexically backward dependence. + bool isBackward() const; + + /// \brief May be a lexically backward dependence type (includes Unknown). bool isPossiblyBackward() const; /// \brief Print the dependence. \p Instr is used to map the instruction diff --git a/lib/Analysis/LoopAccessAnalysis.cpp b/lib/Analysis/LoopAccessAnalysis.cpp index fd85a908ffb..58a7d08860b 100644 --- a/lib/Analysis/LoopAccessAnalysis.cpp +++ b/lib/Analysis/LoopAccessAnalysis.cpp @@ -910,14 +910,14 @@ bool MemoryDepChecker::Dependence::isSafeForVectorization(DepType Type) { llvm_unreachable("unexpected DepType!"); } -bool MemoryDepChecker::Dependence::isPossiblyBackward() const { +bool MemoryDepChecker::Dependence::isBackward() const { switch (Type) { case NoDep: case Forward: case ForwardButPreventsForwarding: + case Unknown: return false; - case Unknown: case BackwardVectorizable: case Backward: case BackwardVectorizableButPreventsForwarding: @@ -926,6 +926,26 @@ bool MemoryDepChecker::Dependence::isPossiblyBackward() const { llvm_unreachable("unexpected DepType!"); } +bool MemoryDepChecker::Dependence::isPossiblyBackward() const { + return isBackward() || Type == Unknown; +} + +bool MemoryDepChecker::Dependence::isForward() const { + switch (Type) { + case Forward: + case ForwardButPreventsForwarding: + return true; + + case NoDep: + case Unknown: + case BackwardVectorizable: + case Backward: + case BackwardVectorizableButPreventsForwarding: + return false; + } + llvm_unreachable("unexpected DepType!"); +} + bool MemoryDepChecker::couldPreventStoreLoadForward(unsigned Distance, unsigned TypeByteSize) { // If loads occur at a distance that is not a multiple of a feasible vector -- 2.34.1