[Beignet] [PATCH v2] add the reduced self loop node detection.

xionghu.luo at intel.com xionghu.luo at intel.com
Tue Nov 18 21:38:30 PST 2014


From: Luo Xionghu <xionghu.luo at intel.com>

if the self loop node is reduced, the llvm loop info couldn't detect
such kind of self loops, handle it by checking whether the compacted
node has a successor pointed to itself.

v2: differentiate the compacted node from basic node to make the logic
clearer, comments the while node as it is not enabled now.

Signed-off-by: Luo Xionghu <xionghu.luo at intel.com>
---
 backend/src/ir/structural_analysis.cpp |   37 ++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 11 deletions(-)

diff --git a/backend/src/ir/structural_analysis.cpp b/backend/src/ir/structural_analysis.cpp
index 21c04f3..4c7e3d2 100644
--- a/backend/src/ir/structural_analysis.cpp
+++ b/backend/src/ir/structural_analysis.cpp
@@ -864,6 +864,9 @@ namespace analysis
         return NULL;
     }
 
+    //FIXME: as our IR could only handle self loop, the while loop node
+    //is disabled to avoid performace regression by the path function.
+#if 0
     /* check for improper region */
     for(NodeList::const_iterator m = nset.begin(); m != nset.end(); m++)
     {
@@ -888,6 +891,8 @@ namespace analysis
         return insertNode(p);
       }
     }
+#endif
+
     return NULL;
   }
 
@@ -1023,18 +1028,28 @@ namespace analysis
           }
 
           Node* loop_header = NULL;
-          for (auto l : loops) {
-            ir::BasicBlock &a = fn->getBlock(l->bbs[0]);
-            loop_header = bbmap.find(&a)->second;
-
-            if(loop_header == n){
-              for (auto bb : l->bbs) {
-                ir::BasicBlock &tmp = fn->getBlock(bb);
-                Node* node_ = bbmap.find(&tmp)->second;
-                reachUnder.push_front(node_);
-                nset.insert(node_);
+          //if n is basic block node, query the llvm loop info to find the loop whoose loop header is n;
+          if(n->type() == BasicBlock){
+            for (auto l : loops) {
+              ir::BasicBlock &a = fn->getBlock(l->bbs[0]);
+              loop_header = bbmap.find(&a)->second;
+
+              if(loop_header == n){
+                for (auto bb : l->bbs) {
+                  ir::BasicBlock &tmp = fn->getBlock(bb);
+                  Node* node_ = bbmap.find(&tmp)->second;
+                  reachUnder.push_front(node_);
+                  nset.insert(node_);
+                }
+                break;
               }
-              break;
+            }
+          }else{
+          //n is compacted node, it would have a successor pointed to itself for self loop.
+            if(n->succs().find(n) != n->succs().end())
+            {
+                reachUnder.push_front(n);
+                nset.insert(n);
             }
           }
 
-- 
1.7.9.5



More information about the Beignet mailing list