[llvm-commits] cttz optimisation
Alastair Lynn
arplynn at gmail.com
Mon Jan 4 22:40:27 PST 2010
Hi Chris-
Here's an updated version of the patch, with the changes you requested and a similar transform for ctlz.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ctz-instcombine.patch
Type: application/octet-stream
Size: 3406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20100105/015ee2a3/attachment.obj>
-------------- next part --------------
On 5 Jan 2010, at 05:18, Chris Lattner wrote:
>
> On Jan 4, 2010, at 8:35 PM, Alastair Lynn wrote:
>
>> Hello-
>>
>> The attached patch catches cases where cttz's value is constant.
>
> Nice transformation, some nitpicks:
>
>
> + APInt Mask(BitWidth, 0);
> + Mask.set(TrailingZeros);
> + Mask = Mask - 1;
>
> Please use APInt::getLowBitsSet
>
> + if ((Mask & KnownZero) == Mask) {
> + return ReplaceInstUsesWith(CI, ConstantInt::get(IT,
> + APInt(BitWidth, TrailingZeros)));
> + }
>
> No need for the braces.
>
> Please add a comment explaining the intuition, something like "If all bits before the first known one are known to be zero, then we can evaluate this symbolically.
>
> Please apply with these changes, thanks Alastair! Want to do a similar patch for ctlz?
>
> -Chris
More information about the llvm-commits
mailing list