[Mesa-dev] [PATCH 1/3] R600: handle loops to self in the structurizer v2

Christian König deathsimple at vodafone.de
Thu Jan 24 04:46:36 PST 2013


v2: don't mess up other loops

Signed-off-by: Christian König <deathsimple at vodafone.de>
Tested-by: Michel Dänzer <michel.daenzer at amd.com>
---
 lib/Target/R600/AMDGPUStructurizeCFG.cpp |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/Target/R600/AMDGPUStructurizeCFG.cpp b/lib/Target/R600/AMDGPUStructurizeCFG.cpp
index 22338b5..5be40de 100644
--- a/lib/Target/R600/AMDGPUStructurizeCFG.cpp
+++ b/lib/Target/R600/AMDGPUStructurizeCFG.cpp
@@ -252,6 +252,11 @@ void AMDGPUStructurizeCFG::analyzeBlock(BasicBlock *BB) {
   BBPredicates &Pred = Predicates[BB];
 
   for (; PI != PE; ++PI) {
+
+    // Ignore self loops
+    if (*PI == BB)
+      continue;
+
     BranchInst *Term = cast<BranchInst>((*PI)->getTerminator());
 
     for (unsigned i = 0, e = Term->getNumSuccessors(); i != e; ++i) {
@@ -296,7 +301,9 @@ void AMDGPUStructurizeCFG::collectInfos() {
   LoopPred.clear();
 
   RNVector::reverse_iterator OI = Order.rbegin(), OE = Order.rend();
-  for (Visited.clear(); OI != OE; Visited[(*OI++)->getEntry()] = ++Number) {
+  for (Visited.clear(); OI != OE; ++OI) {
+
+    Visited[(*OI)->getEntry()] = ++Number;
 
     // Analyze all the conditions leading to a node
     analyzeBlock((*OI)->getEntry());
@@ -568,6 +575,8 @@ void AMDGPUStructurizeCFG::createFlow() {
     Predicates[Split] = Predicates[Prev];
     Order.push_back(ParentRegion->getBBNode(Split));
     LoopPred[Prev] = BoolTrue;
+    if (LoopEnd == Prev)
+      LoopEnd = Split;
 
   } else if (LoopStart == Order.back()->getEntry()) {
     // Loop starts behind entry, split entry so that we can jump to it
-- 
1.7.9.5



More information about the mesa-dev mailing list