[PATCH] D15496: [InstCombine] Identify partial bitreverses
James Molloy via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 14 07:45:20 PST 2015
jmolloy created this revision.
jmolloy added reviewers: hfinkel, sbaranga, sanjoy.
jmolloy added subscribers: majnemer, llvm-commits.
jmolloy set the repository for this revision to rL LLVM.
It could be beneficial to emit a bitreverse intrinsic even when some of the result of that intrinsic need to be masked out. For example, assume we have a bitreverse but just without some bits:
int4_t b = 0;
if (a & 1) b |= 8;
if (a & 2) b |= 4;
// (a & 4) -> (b |= 2) is missing
if (a & 8) b |= 1;
Here, we can simply perform the bitreverse and mask: (res &= ~2).
This patch provides support for this. Obviously, doing this unconditionally would not be a good idea. A single bit move that happens to be correct for a bitreversal will cause a bitreverse (which may not be cheap on the target) and mask to be emitted. Therefore in this patch we heuristically say that if a bitreverse would require more than half its bits masked out not to bother. Perhaps this should be a target hook, depending on whether bitreverse is cheap or not?
Repository:
rL LLVM
http://reviews.llvm.org/D15496
Files:
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
test/Transforms/InstCombine/bitreverse-partial.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15496.42720.patch
Type: text/x-patch
Size: 4522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151214/3bcd2c66/attachment.bin>
More information about the llvm-commits
mailing list