[PATCH] D123607: LowerSwitch: Avoid inserting NewDefault block
Ruiling, Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 12 06:44:03 PDT 2022
ruiling created this revision.
ruiling added reviewers: arsenm, foad, nhaehnle.
Herald added subscribers: kerbowa, hiraditya, jvesely.
Herald added a project: All.
ruiling requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.
The NewDefault was used to simplify the updating of PHI nodes, but it
causes some inefficiency for target that will run structurizer later. For
example, for a simple two-case switch, the extra NewDefault is causing
unstructured CFG like:
O
/ \
O O
/ \ / \
C1 ND C2
\ | /
\ | /
D
The change is to avoid the ND(NewDefault) block, that is we will get a
structured CFG for above example like:
O
/ \
/ \
O O
/ \ / \
C1 \ / C2
\-> D <-/
The IR change introduced by this patch should be trivial to other targets,
so I am doing this unconditionally.
Fall-through among the cases will also cause unstructured CFG, but it need
more work and will be addressed in a separate change.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D123607
Files:
llvm/lib/Transforms/Utils/LowerSwitch.cpp
llvm/test/CodeGen/AMDGPU/multilevel-break.ll
llvm/test/Transforms/FixIrreducible/switch.ll
llvm/test/Transforms/LowerSwitch/2014-06-23-PHIlowering.ll
llvm/test/Transforms/LowerSwitch/do-not-handle-impossible-values.ll
llvm/test/Transforms/LowerSwitch/feature.ll
llvm/test/Transforms/StructurizeCFG/interleaved-loop-order.ll
llvm/test/Transforms/UnifyLoopExits/switch.ll
llvm/test/Transforms/Util/lowerswitch.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123607.422216.patch
Type: text/x-patch
Size: 37305 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220412/8716c02a/attachment.bin>
More information about the llvm-commits
mailing list