httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dean Gaudet <>
Subject Re: [PATCH] murderous HUP
Date Tue, 18 Feb 1997 22:27:02 GMT
On Tue, 18 Feb 1997, Marc Slemko wrote:
> Is there any reason to bother with a shift, or are compilers good enough
> that they will implement multiplication by powers of two that way anyway? 

Yeah for any of the "easy" constants you can assume the compiler will
optimize it for you.  For others it's often not easy to decide when it's
worth the extra registers required to pull some of the fancy constant
multiplication tricks... not to mention the result code side-effects which
might not let it pipeline, and so on.  Powers of 2 should be easy on every
modern CPU. 

And also, while I'm babbling away, since integer division instructions
typically provide both the quotient and remainder as results some
compilers will optimize "a/1000000" and "a%1000000" into a single
instruction with two side-effects.  gcc -O on i386 does this, haven't
checked other architectures.  ANSI C provides the div() and ldiv() library
functions to presumably let the vendor provide this without the extra gear
in the compiler.  Another case of this is sin(t), cos(t) since it's easy
to produce both at the same time, some FPUs have a "sincos" instruction. 


View raw message