[PATCH] D69689: [SimplifyCFG] Use a (trivially) dominanting widenable branch to remove later slow path blocks

Artur Pilipenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 31 17:40:06 PDT 2019


apilipenko added inline comments.


================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:3234-3252
+  auto NoSideEffects = [](BasicBlock &BB) {
+    return !llvm::any_of(BB, [](const Instruction &I) {
+        return I.mayWriteToMemory() || I.mayHaveSideEffects();
+      });
+  };
+  if (BI->getSuccessor(1) != IfFalseBB && // no inf looping
+      BI->getSuccessor(1)->getTerminatingDeoptimizeCall() && // profitability
----------------
This can be structured better. First, you need `NoSideEffects(*BI->getParent())` for both of the cases, so it can be turned into an early return check. And second, these cases seem to differ only by successor index. Factor out a lambda and call it for 0 and 1?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69689/new/

https://reviews.llvm.org/D69689





More information about the llvm-commits mailing list