[llvm-commits] [llvm] r120028 - in /llvm/trunk: lib/Target/README.txt lib/Transforms/InstCombine/InstCombineShifts.cpp test/Transforms/InstCombine/shift.ll

Benjamin Kramer benny.kra at googlemail.com
Tue Nov 23 12:29:25 PST 2010


On 23.11.2010, at 21:05, Benjamin Kramer wrote:

> 
> On 23.11.2010, at 20:20, Chris Lattner wrote:
> 
>> 
>> On Nov 23, 2010, at 10:52 AM, Benjamin Kramer wrote:
>> 
>>> Author: d0k
>>> Date: Tue Nov 23 12:52:42 2010
>>> New Revision: 120028
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=120028&view=rev
>>> Log:
>>> 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 :(





More information about the llvm-commits mailing list