[PATCH] D69689: [SimplifyCFG] Use a (trivially) dominanting widenable branch to remove later slow path blocks
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 1 15:21:16 PDT 2019
reames marked an inline comment as done.
reames 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
----------------
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.
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