summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuo Xionghu <xionghu.luo@intel.com>2014-11-19 13:38:30 +0800
committerZhigang Gong <zhigang.gong@intel.com>2015-01-12 09:30:54 +0800
commit26a9ea3167baf0e097d6497e7e627ac791cd49fa (patch)
tree9c0f7b55afbb9ca71e4380a1af7e4d879434a899
parent0fe78464613b4aee37f8a63a83ce0072bb821316 (diff)
downloadbeignet-26a9ea3167baf0e097d6497e7e627ac791cd49fa.tar.gz
add the reduced self loop node detection.
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@intel.com> Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r--backend/src/ir/structural_analysis.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/backend/src/ir/structural_analysis.cpp b/backend/src/ir/structural_analysis.cpp
index 21c04f39..4c7e3d21 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);
}
}