summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize
diff options
context:
space:
mode:
authorFlorian Hahn <florian.hahn@arm.com>2018-03-02 12:24:25 +0000
committerFlorian Hahn <florian.hahn@arm.com>2018-03-02 12:24:25 +0000
commit515acd64fd100322c92691971674399155132dfe (patch)
tree56acd0a2cca20ae440128c98dafde7ff8e95ec2a /llvm/lib/Transforms/Vectorize
parentb46c191c4979bde12a11c8f087a874e810a625b7 (diff)
downloadbcm5719-llvm-515acd64fd100322c92691971674399155132dfe.tar.gz
bcm5719-llvm-515acd64fd100322c92691971674399155132dfe.zip
[LV][CFG] Add irreducible CFG detection for outer loops
This patch adds support for detecting outer loops with irreducible control flow in LV. Current detection uses SCCs and only works for innermost loops. This patch adds a utility function that works on any CFG, given its RPO traversal and its LoopInfoBase. This function is a generalization of isIrreducibleCFG from lib/CodeGen/ShrinkWrap.cpp. The code in lib/CodeGen/ShrinkWrap.cpp is also updated to use the new generic utility function. Patch by Diego Caballero <diego.caballero@intel.com> Differential Revision: https://reviews.llvm.org/D40874 llvm-svn: 326568
Diffstat (limited to 'llvm/lib/Transforms/Vectorize')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoopVectorize.cpp31
1 files changed, 8 insertions, 23 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 47a767ccbbe..d8d21dfcb85 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -56,7 +56,6 @@
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/None.h"
#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/SCCIterator.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
@@ -69,6 +68,7 @@
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
+#include "llvm/Analysis/CFG.h"
#include "llvm/Analysis/CodeMetrics.h"
#include "llvm/Analysis/DemandedBits.h"
#include "llvm/Analysis/GlobalsModRef.h"
@@ -283,24 +283,6 @@ class LoopVectorizationRequirements;
} // end anonymous namespace
-/// Returns true if the given loop body has a cycle, excluding the loop
-/// itself.
-static bool hasCyclesInLoopBody(const Loop &L) {
- if (!L.empty())
- return true;
-
- for (const auto &SCC :
- make_range(scc_iterator<Loop, LoopBodyTraits>::begin(L),
- scc_iterator<Loop, LoopBodyTraits>::end(L))) {
- if (SCC.size() > 1) {
- DEBUG(dbgs() << "LVL: Detected a cycle in the loop body:\n");
- DEBUG(L.dump());
- return true;
- }
- }
- return false;
-}
-
/// A helper function for converting Scalar types to vector types.
/// If the incoming type is void, we return void. If the VF is 1, we return
/// the scalar type.
@@ -2302,14 +2284,17 @@ private:
} // end anonymous namespace
-static void addAcyclicInnerLoop(Loop &L, SmallVectorImpl<Loop *> &V) {
+static void addAcyclicInnerLoop(Loop &L, LoopInfo &LI,
+ SmallVectorImpl<Loop *> &V) {
if (L.empty()) {
- if (!hasCyclesInLoopBody(L))
+ LoopBlocksRPO RPOT(&L);
+ RPOT.perform(&LI);
+ if (!containsIrreducibleCFG<const BasicBlock *>(RPOT, LI))
V.push_back(&L);
return;
}
for (Loop *InnerL : L)
- addAcyclicInnerLoop(*InnerL, V);
+ addAcyclicInnerLoop(*InnerL, LI, V);
}
namespace {
@@ -8637,7 +8622,7 @@ bool LoopVectorizePass::runImpl(
SmallVector<Loop *, 8> Worklist;
for (Loop *L : *LI)
- addAcyclicInnerLoop(*L, Worklist);
+ addAcyclicInnerLoop(*L, *LI, Worklist);
LoopsAnalyzed += Worklist.size();
OpenPOWER on IntegriCloud