diff options
author | Luo Xionghu <xionghu.luo@intel.com> | 2014-11-19 13:38:30 +0800 |
---|---|---|
committer | Zhigang Gong <zhigang.gong@intel.com> | 2014-11-19 13:13:30 +0800 |
commit | 6fd5b39a18153be70d8cf22a115973188da4829a (patch) | |
tree | e45c6c6c01ad11655bfd167aa1e85d85da53cdc0 | |
parent | 406f68fdc14c6240945bcd81ab5925f9356d6a83 (diff) |
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.cpp | 37 |
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); } } |