Re: Unsigned Long Long
Re: Unsigned Long Long
- Subject: Re: Unsigned Long Long
- From: Marcel Weiher <email@hidden>
- Date: Thu, 13 May 2004 19:14:07 +0100
On 13 May 2004, at 15:05, Sherm Pendley wrote:
On May 13, 2004, at 8:31 AM, Clark Cox wrote:
"always" is a dangerous word...
Yep - it's not a word I like to use. I'm just repeating what every
text book, paper, tutorial, etc., has told me. And experience has
borne it out - every CPU I'm aware of has hardware bit-shifting
instructions that are substantially faster than its integer divide
instructions, which are generally implemented in microcode.
That used to be true of multiply as well, now we've got CPUs with
single-cycle floating point multiply-add instructions. I am not making
a prediction that the same will happen with divide, but things change.
No, I'm suggesting that you test the assumption that "GCC doesn't
optimize division by a constant power of 2 into a bit-shift on its
own"
Why would I want to do that?
Test the assumption or write the code as "divide" rather than shift? I
probably wouldn't do the former, unless I notice a puzzling performance
problem, as I don't think any 'serious' compiler doesn't do this
optimization.
As for the latter, I would *always* want to write the operation I
*intend*, instead of substituting a *different* operation that I know
has the same effect for a (machine-)specific number representation.
That's the compiler's job, and intention-revealing code is something
very near and dear to my heart.
Marcel
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.