[llvm-dev] CFG normalization: avoiding `br i1 false`

Davide Italiano via llvm-dev llvm-dev at lists.llvm.org
Wed Nov 29 10:08:18 PST 2017


On Wed, Nov 29, 2017 at 9:48 AM, Philip Reames
<listmail at philipreames.com> wrote:
> There's already a LoopSimplifyCFG which is a loop-pass (and thus can iterate
> with other loop passes) and eliminates trivial branches.  Having a simple
> pass which just strips unreachable blocks and converts conditional branches
> to unconditional ones while updating appropriate analyzes (LoopInfo,
> DomTree, LCSSA, etc..) seems very reasonable.

I'm not necessarily convinced having one-trick-pony pass is the best
option here.
It adds complexity, and there's already a pass in-tree which can
provide this functionality.
What are your concerns about running SimplifyCFG more often? It
shouldn't be a compile-time sink

> This could also be a utility
> function called from the end of other passes.  The hard bit is the analysis
> preservation.  A good place to copy from might be the recent loop-unswitch
> work Chandler did.
>
> Philip
>

I don't think preserving the analyses is extremely hard (but I may be
wrong on this).
The incremental Dominator tree API makes the updates fairly easy.
LCSSA is slightly more complicated.
If you take a look at the new LoopUnswitch, in fact, it does call
recalculate rather than fixing it incrementally.
But, if LCSSA is computed right, recomputing entirely should take very
little time.

Thanks,

--
Davide


More information about the llvm-dev mailing list