[PATCH] D101290: [LV] Try to sink and hoist inside candidate loops for vectorization.
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 27 10:28:23 PDT 2021
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.
Cautious LG, you likely want one more review.
================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:9998
+ // Remove block if it became dead.
+ if (pred_begin(BB) == pred_end(BB)) {
+ LI.removeBlock(BB);
----------------
pred_empty(BB)
================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10008-10011
+ BI->getSuccessor(0)->getSinglePredecessor() &&
+ BI->getSuccessor(1)->getSinglePredecessor() &&
+ all_of(successors(BB), [&LI, L](BasicBlock *Succ) {
+ return LI.getLoopFor(Succ) == L;
----------------
================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10015
+ auto *OldElse = BI->getSuccessor(1);
+ if (hoistThenElseCodeToIf(BI, TTI, false, &DTU)) {
+ Changed = true;
----------------
================
Comment at: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:10006-10016
+ if (hoistThenElseCodeToIf(BI, TTI, false, &DTU)) {
+ Changed = true;
+ SmallPtrSet<BasicBlock *, 2> NewSuccs(succ_begin(BB), succ_end(BB));
+ if (!NewSuccs.count(OldThen)) {
+ LI.removeBlock(OldThen);
+ DeleteDeadBlock(OldThen);
+ }
----------------
fhahn wrote:
> lebedev.ri wrote:
> > I think it would be fine to sink that into `hoistThenElseCodeToIf()`.
> Unfortunately I think that would be incompatible with the use in SimplifyCFG, which does not seem to handle removing BBs other than the current one well.
>
> But I adjusted the loop to remove any blocks that became dead at the top-level, which hopefully makes things a bit clearer.
Hmm, true. Disregard then.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101290/new/
https://reviews.llvm.org/D101290
More information about the llvm-commits
mailing list