[PATCH] D33694: [PartialInlining] : Partial inlining Overhead reduction: eliminate unnecessary live-out(s)

Wei Mi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 31 16:14:51 PDT 2017


wmi accepted this revision.
wmi added a comment.
This revision is now accepted and ready to land.

LGTM. Only a minor comment.



================
Comment at: lib/Transforms/IPO/PartialInlining.cpp:660-670
+    Value *CommonValue = nullptr;
+    for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) {
+      Value *PhiOpnd = PN->getIncomingValue(i);
+      if (!CommonValue)
+        CommonValue = PhiOpnd;
+      else if (CommonValue != PhiOpnd) {
+        CommonValue = nullptr;
----------------
Maybe a little bit simpler to use find_if, but I am not sure. 

```
if (find_if(PN->incoming_values(), std::bind2nd(std::not_equal_to<Value *>(), PN->getIncomingValue(0)))
        != PN->incoming_values().end())
  return (Value *)nullptr;
return PN->getIncomingValue(0); 
```



https://reviews.llvm.org/D33694





More information about the llvm-commits mailing list