Re: Unsigned Long Long
Re: Unsigned Long Long
- Subject: Re: Unsigned Long Long
- From: Sherm Pendley <email@hidden>
- Date: Thu, 13 May 2004 10:05:18 -0400
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.
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? If I assume a non-optimizing compiler and
use >>, I get the faster bit-shifting instructions every time, with any
compiler. There's no need to test anything, because the optimal
bit-shifting code will always be produced regardless of whether the
compiler is also capable of optimizing / to produce it.
The opposite is not true however - If I were to assume an optimizing
compiler that produces bit-shifting instructions from /, then I'd have
to test that assumption every time I switched to a different compiler,
because one for which my assumption were false would produce
sub-optimal code.
sherm--
_______________________________________________
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.