Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: src/IceLoopAnalyzer.cpp

Issue 1416113007: Subzero: Recognize single-block loops during loop depth analysis. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/IceLoopAnalyzer.h ('k') | tests_lit/llvm2ice_tests/loop-nest-depth.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceLoopAnalyzer.cpp
diff --git a/src/IceLoopAnalyzer.cpp b/src/IceLoopAnalyzer.cpp
index 4e1b5492560a7c54971f77c81114d8ebe4dbc0be..17aaaf172815a0ff52cb8eb1aed5514724d71b6e 100644
--- a/src/IceLoopAnalyzer.cpp
+++ b/src/IceLoopAnalyzer.cpp
@@ -34,6 +34,14 @@ void LoopAnalyzer::LoopNode::incrementLoopNestDepth() {
BB->incrementLoopNestDepth();
}
+bool LoopAnalyzer::LoopNode::hasSelfEdge() const {
+ for (CfgNode *Succ : BB->getOutEdges()) {
+ if (Succ == BB)
+ return true;
+ }
+ return false;
+}
+
LoopAnalyzer::LoopAnalyzer(Cfg *Fn) : Func(Fn) {
const NodeList &Nodes = Func->getNodes();
@@ -115,6 +123,8 @@ LoopAnalyzer::processNode(LoopAnalyzer::LoopNode &Node) {
// Single node means no loop in the CFG
if (LoopStack.back() == &Node) {
LoopStack.back()->setOnStack(false);
+ if (Node.hasSelfEdge())
+ LoopStack.back()->incrementLoopNestDepth();
LoopStack.back()->setDeleted();
++NumDeletedNodes;
LoopStack.pop_back();
« no previous file with comments | « src/IceLoopAnalyzer.h ('k') | tests_lit/llvm2ice_tests/loop-nest-depth.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698