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?
Should this be "false if not"?