[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
Fri Nov 1 19:53:59 PDT 2019


apilipenko accepted this revision.
apilipenko added inline comments.
This revision is now accepted and ready to land.


================
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
----------------
reames wrote:
> apilipenko wrote:
> > 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?
> The use of the lambda here is important.  I only want to evaluate the expensive predicate if both of the cheap ones have passed.  
> 
> As for the second point, possible.  I played with a couple and nothing really seemed cleaner, but I can give it another attempt.  
Ah, makes sense. May be a comment explaining the use of the lambda then?


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