[WebAssembly] Optimize the number of routing blocks in FixIrreducibleCFG
authorHeejin Ahn <aheejin@gmail.com>
Sat, 30 Mar 2019 01:31:11 +0000 (01:31 +0000)
committerHeejin Ahn <aheejin@gmail.com>
Sat, 30 Mar 2019 01:31:11 +0000 (01:31 +0000)
commit7e7aad1510682498426009dc1638d4e9b77447c7
treeea5ecd17b83997fe8d2a2c0a5ef5b8fe1e363366
parent916709e0be4469dd798de32026b922ace5ce8e59
[WebAssembly] Optimize the number of routing blocks in FixIrreducibleCFG

Summary:
Currently we create a routing block to the dispatch block for every
predecessor of every entry. So the total number of routing blocks
created will be (# of preds) * (# of entries). But we don't need to do
this: we need at most 2 routing blocks per loop entry, one for when the
predecessor is inside the loop and one for it is outside the loop. (We
can't merge these into one because this will creates another loop cycle
between blocks inside and blocks outside) This patch fixes this and
creates at most 2 routing blocks per entry.

This also renames variable `Split` to `Routing`, which I think is a bit
clearer.

Reviewers: kripken

Subscribers: sunfish, dschuff, sbc100, jgravelle-google, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59462

llvm-svn: 357337
llvm/lib/Target/WebAssembly/WebAssemblyFixIrreducibleControlFlow.cpp
llvm/test/CodeGen/WebAssembly/irreducible-cfg.ll
llvm/test/CodeGen/WebAssembly/irreducible-cfg.mir [new file with mode: 0644]