mpz_{eq,lt,gt}_{ui,si}_p macros?

Vincent Lefevre vincent at vinc17.net
Mon Feb 11 01:12:29 CET 2013


On 2013-02-11 00:24:12 +0100, Marc Glisse wrote:
> On Sun, 10 Feb 2013, bodrato at 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 <vincent at 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)


More information about the gmp-devel mailing list