[PATCH] D54023: [LoopSimplifyCFG] Delete dead in-loop blocks
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 20 23:17:50 PST 2018
mkazantsev added inline comments.
================
Comment at: lib/Transforms/Scalar/LoopSimplifyCFG.cpp:240
+ LI.removeBlock(BB);
+ DeleteDeadBlock(BB, &DTU);
+ ++NumLoopBlocksDeleted;
----------------
mkazantsev wrote:
> anna wrote:
> > So, this removes the dead block and updates DT.
> > However, what about this case:
> > ```
> > deadblock:
> > br anotherblock:
> >
> > anotherblock:
> > <no phis, so we're guaranteed there's exactly one pred, which is deadblock>
> >
> > ```
> > DeleteDeadBlock does not recursively remove dead blocks. It handles the case where: `dead block` is *one of the predecessors* of `anotherblock` - see `BasicBlock::removePredecessor`.
> >
> > I don't think `DeadLoopBlocks` contains `anotherblock`, since it became dead/unreachable when `deadblock` is dead.
> >
> `DeadLoopBlocks` must contain it by construction, otherwise it's a bug.
> I'll add tests on that.
Actually we already test this in tests `dead_block_propogate_test_branch_loop`. In this test, block `dead` is dead because its predecessor goes to it by false condition, and `dummy` is dead because `dead` is its only predecessor.
It is all handled by the algorithm that collects our block sets: it knows what blocks will be dead after *all* folding will be done. It knows it all in advance.
https://reviews.llvm.org/D54023
More information about the llvm-commits
mailing list