This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fold integer divisions to arithmetic shifts


On 10/19/2010 02:43 AM, Dmitry Melnik wrote:
> On 10/14/2010 08:32 PM, Jakub Jelinek wrote:
> 
>> Consider
>> long long x = foo ();
>> x = (x & -0x200000000LL) / 0x200000000LL;
>> The above code would optimize this as
>> x = x >> -1;
>> on 32-bit HWI targets.  Also, I think checking that arg1 is actually
>> INTEGER_CST would be desirable too (integer_pow2p can return true
>> even for COMPLEX_CST and then tree_int_cst_sgn accesses something the
>> COMPLEX_CST doesn't have).
> 
> I've modified the patch similarly to http://gcc.gnu.org/ml/gcc-patches/2010-10/msg01282.html, added
> check for INTEGER_CST, and modified test to check for shift operation in 'optimized' dump.
> Bootstrapped and regtested on x86_64 and i686.
> Ok now?

Yes, this is ok.


r~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]