[llvm-commits] cttz optimisation

Chris Lattner clattner at apple.com
Mon Jan 4 23:24:17 PST 2010


On Jan 4, 2010, at 10:40 PM, Alastair Lynn wrote:

> Hi Chris-
> 
> Here's an updated version of the patch, with the changes you requested and a similar transform for ctlz.

Great!  Applied as r92706.  Thanks again,

-Chris

> 
> <ctz-instcombine.patch>
> 
> 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
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits





More information about the llvm-commits mailing list