[PATCH] D102615: [LoopDeletion] Break backedge if we can prove that the loop is exited on 1st iteration
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 24 21:22:05 PDT 2021
mkazantsev added inline comments.
================
Comment at: llvm/lib/Transforms/Scalar/LoopDeletion.cpp:204
+ auto GetOnlyLivePred = [&](BasicBlock * BB)->BasicBlock * {
+ if (BB == Header)
+ return L->getLoopPredecessor();
----------------
reames wrote:
> This check should probably be lifted to caller, and assert !Header here. It confuses the interface of this lambda.
>
> You could also consider renaming the lambda to getSolePredecessorOnFirstIteration.
But why lifting it out? Semantically the sole predecessor of header on the 1st iteration is a loop pred. This allows us to process all loop blocks uniformly. Why do you think that header should be a special case outside this function?
================
Comment at: llvm/lib/Transforms/Scalar/LoopDeletion.cpp:210
+ // 2 live preds.
+ if (OnlyPred)
+ return nullptr;
----------------
reames wrote:
> Note that predecessors can be listed multiple times due to switches. You should check that OnlyPred is non-null and not equal to this block.
Good point, I'll add a test for this.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102615/new/
https://reviews.llvm.org/D102615
More information about the llvm-commits
mailing list