[PATCH] D37343: [CGP] Merge empty case blocks if no extra moves are added.

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 3 17:36:11 PDT 2017


kuhar added inline comments.


================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:776
 
-    bool HasAllSameValue = true;
-    BasicBlock::const_iterator DestBBI = DestBB->begin();
-    while (const PHINode *DestPN = dyn_cast<PHINode>(DestBBI++)) {
-      if (DestPN->getIncomingValueForBlock(BB) !=
-          DestPN->getIncomingValueForBlock(DestBBPred)) {
-        HasAllSameValue = false;
-        break;
-      }
-    }
-    if (HasAllSameValue)
+    if (llvm::none_of(PNs, [&](PHINode *PN) {
+      return (PN->getIncomingValueForBlock(BB) !=
----------------
Isn't this the same thing as saying `all_of(PNs, ... == ...)`? I think that would be more straight-forward and easy to read here.


================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:951
   BB->replaceAllUsesWith(DestBB);
+  if (!Updates.empty())
+    DT->applyUpdates(Updates);
----------------
I think that it'd be better to leave this micro-optimization for the updater to do :)
I'll add it there tomorrow.


https://reviews.llvm.org/D37343





More information about the llvm-commits mailing list