On 2013-02-11 00:24:12 +0100, Marc Glisse wrote: > On Sun, 10 Feb 2013, bodr...@mail.dm.unipi.it wrote: > > >I do not know if current gcc can optimise a loop like: > >for (int i = 3; (i < 1 << 30) && mpz_gt_ui_p (z, i); i <<= 1) ; > >but we give it the chance to. > > You should use i*=2 instead of i<<=1 to maximize optimization > opportunities.
Why? I would say that a good compiler has more chances to optimize i<<=1 as the only difference between these two forms is that in the latter one, i is required to be nonnegative. Thus i<<=1 gives more information to the compiler. -- Vincent Lefèvre <vinc...@vinc17.net> - Web: <http://www.vinc17.net/> 100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/> Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon) _______________________________________________ gmp-devel mailing list gmp-devel@gmplib.org http://gmplib.org/mailman/listinfo/gmp-devel