[PATCH] Tweaks for constant-equality-comparisons in BPI

Hal Finkel hfinkel at anl.gov
Mon Oct 28 00:42:10 PDT 2013


Hello again,

There are two other suggestions from (http://impact.crhc.illinois.edu/shared/papers/pact-98-branchpred.pdf) that I think would be useful to adopt in BranchProbabilityInfo (I've divided this into two patches, although the second applies on top of the first):

 1. Treat equality comparisons to -1 as unlikely to succeed. As pointed out in the paper, -1 is often used as an 'invalid index' indicator, and, FWIW, many POSIX(-like) functions return -1 to indicate an error.

 2. Treat single-bit tests as unlikely to succeed. The rationale is that when bit fields are used, the more-likely (default) case is for each bit to be unset. What I've done here is invert the result for an equality comparison with zero in the case where the comparison input is known to be a power of two or zero (and, thus, may only have one bit set).

    For this second case, two regression tests needed updating:
    CodeGen/AArch64/tst-br.ll
    CodeGen/ARM/2013-10-11-select-stalls.ll (given the symmetry here, it is not clear to me why the number of stalls changes here at all; Andy?)

I don't see any significant test-suite changes as a result of these (my x86 test environment timings are pretty noisy, however, so I've run multiple baselines and patched runs, and even so, would not really detect small changes).

Please review.

Thanks again,
Hal

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bpi-neg1-unlikely.patch
Type: text/x-patch
Size: 2259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131028/d38d58eb/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bpi-bitset-unlikely.patch
Type: text/x-patch
Size: 3127 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131028/d38d58eb/attachment-0001.bin>


More information about the llvm-commits mailing list