[llvm-commits] Div->[USF]Div Patch, Attempt #2

Chris Lattner clattner at apple.com
Thu Oct 26 09:54:15 PDT 2006


On Oct 25, 2006, at 9:57 PM, Reid Spencer wrote:
>> This code is a bit simpler as:
>>
>>
>>     // (X / C1) / C2  -> X / (C1*C2)
>>     if (BinaryOperator *LHS = dyn_cast<BinaryOperator>(Op0))
>>       if (LHS->getOpcode() == I.getOpcode())
>>
>
> Didn't apply this because it causes a compiler warning about
> signed/unsigned comparison.

Ok.

>>   // udiv X, (Select Cond, C1, C2) --> Select Cond, (shr X, C1), (shr
>> X, C2)
>>   // where C1&C2 are powers of two.
>> ...
>>                 X = InsertNewInstBefore(
>>                   new CastInst(X, X->getType()->getUnsignedVersion 
>> ()),
>> I);
>>
>>
>> This (and similar cases) is easier/cleaner with InsertCastBefore.
>
> Yes, I agree. I changed the ones in my code but there are actually
> dozens (hundreds) of instances in the file (not related to my  
> changes).
> I'm going to commit the DIV patch first, then I'll come back and clean
> up the others in a separate patch (tested, of course).

Ok, sounds good.

> Thanks for your excellent reviews, Chris. I know it takes a lot of  
> your
> time and I appreciate that you so willingly give it. I'll apply what I
> learned from DIV to the REM patch which I'm reviewing for Sheng soon.
> Hopefully REM will fare better than DIV did.

Sounds good, I'm sure it will get more smooth as it goes on.  Thanks  
for the great improvements Reid!

-Chris



More information about the llvm-commits mailing list