[llvm-commits] [llvm] r120028 - in /llvm/trunk:	lib/Target/README.txt	lib/Transforms/InstCombine/InstCombineShifts.cpp	test/Transforms/InstCombine/shift.ll
    Chris Lattner 
    clattner at apple.com
       
    Tue Nov 23 12:42:51 PST 2010
    
    
  
On Nov 23, 2010, at 12:29 PM, Benjamin Kramer wrote:
>>>> InstCombine: Reduce "X shift (A srem B)" to "X shift (A urem B)" iff B is positive.
>>>> 
>>>> This allows to transform the rem in "1 << ((int)x % 8);" to an and.
>>> 
>>> Nifty.  Could this be generalized into SimplifyDemandedBits?  It seems that the srem simplifies because the shift doesn't need all the result bits of it.
>> 
>> I'm not sure that's safe, this optimization relies on the fact that any shift by an amount <= 0 is undefined.
> 
> Urgh, shifts by 0 _are_ well defined, so this transform is unsafe for everything that's not a power of two. Will fix :(
Ok, does that mean it can be moved to simplify demanded bits too? :)
-Chris
    
    
More information about the llvm-commits
mailing list