[llvm-commits] [Review request] [PR8714] Jump threading of indirectbr blocks (and more)

Frits van Bommel fvbommel at gmail.com
Thu Dec 2 09:10:33 PST 2010


The first four attached patches implement jump threading of
'indirectbr' instructions when the address being jumped to is a known
blockaddress in a predecessor (or just a constant block address), in
these stages:
0) Remove trailing whitespace.
1) Refactor jump threading. Should have no functional change other
than the order of two transformations that are mutually-exclusive[1]
and the exact formatting of debug output. Internally, it now stores
the ConstantInt*s as Constant*s, and actual undef values instead of
nulls. Splitting this out hopefully makes the actual patch much
simpler to review.
2) Add a test case for (3).
3) Actually implement jump threading of 'indirectbr' by keeping track
of whether we're looking for ConstantInt*s or BlockAddress*s.

[1]: I had to switch them because that was the only place where it
used to test for ConstantInt without also testing for UndefinedValue,
and I wanted to factor out the (ConstantInt || UndefValue) test so I
could add BlockAddress later.

By the way, I wasn't sure what "bonus" to give for threading over an
indirectbr. I figured a bit more than the one for threading over a
switch, but I could be completely off base here. Anyone?


While working on this I noticed that "opt -O3" turned the phi in my
original testcase into a select and didn't further optimize it, so
that the indirectbr wasn't eliminated. To fix this, patch #5 teaches
SimplifyCFG (which created the select) to simplify (indirectbr (select
cond, blockaddress(@fn, BlockA), blockaddress(@fn, BlockB))) to (br
cond, BlockA, BlockB). Patch #4 is a test for this.


Comments?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 000-jumpthreading-whitespace.patch
Type: text/x-patch
Size: 43681 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101202/24c05ae8/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 001-jumpthreading-nonnull-undef.patch
Type: text/x-patch
Size: 13028 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101202/24c05ae8/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 002-jumpthreading-indrectbr-test.patch
Type: text/x-patch
Size: 1941 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101202/24c05ae8/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 003-jumpthreading-indirectbr.patch
Type: text/x-patch
Size: 12040 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101202/24c05ae8/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 004-simplifycfg-indirectbr-of-select-test.patch
Type: text/x-patch
Size: 3940 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101202/24c05ae8/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 005-simplifycfg-indirectbr-of-select.patch
Type: text/x-patch
Size: 3574 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101202/24c05ae8/attachment-0005.bin>


More information about the llvm-commits mailing list