[PATCH] D132356: [SimplifyCFG] Don't widen cond br to cond br if false branch has successors

Artur Pilipenko via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 22 18:39:40 PDT 2022


apilipenko added a comment.

So, you are crippling this transformation to avoid an infinite loop with another transform in SimplifyCFG. This is probably OK as we still handle the common case of a widenable condition going to a deoptimization block.



================
Comment at: llvm/lib/Transforms/Utils/SimplifyCFG.cpp:4010
       BI->getSuccessor(1)->getTerminatingDeoptimizeCall() && // profitability
+      llvm::succ_empty(IfFalseBB) &&
       NoSideEffects(*BI->getParent())) {
----------------
No need to check it twice. Just check if after line 4001 once. 

Also, please add a comment on why you are restricting this transformation with a TODO to find a more fine-grained solution. 


================
Comment at: llvm/test/Transforms/SimplifyCFG/pr52290.ll:32
 bb1:                                              ; preds = %bb
   br i1 undef, label %bb7, label %bb5
 
----------------
Before you make this change, please, update the tests and remove branching on undef. This is UB and the optimizer can do whatever for this test. This can be done in a separate patch without additional review. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132356



More information about the llvm-commits mailing list