[PATCH] D35609: [LICM] Make sinkRegion and hoistRegion non-recursive

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 19 18:25:06 PDT 2017


sanjoy added inline comments.


================
Comment at: lib/Transforms/Scalar/LICM.cpp:349
+    for (DomTreeNode *Child : DTN->getChildren())
+      add_region_to_worklist(Child);
+  }
----------------
Not sure that the lambda is actually useful here -- why not just:

```
if (CurLoop->contains(Child->getBlock()))
  Worklist.push_back(CurLoop);
```
?

If you wanted to go a bit further, I'd say even

```
for (size_t i = 0; i < Worklist.size(); i++)
  copy_if(Worklist[i]->getChildren(), <lambda to check if node is in loop>, std::back_inserter(Worklist));
```

may work.


https://reviews.llvm.org/D35609





More information about the llvm-commits mailing list