Re: The performance of all kinds of C operations
- From: websnarf@xxxxxxxxx
- Date: 17 Jun 2006 09:50:44 -0700
Nick Keighley wrote:
websnarf@xxxxxxxxx wrote:
Nick Keighley wrote:
websnarf@xxxxxxxxx wrote:
Eric Sosman wrote:
websnarf@xxxxxxxxx wrote:
spibou@xxxxxxxxx wrote:
I didn't read your whole page but had a look at the table in the
section "Strictly for beginners". Can you explain why would
"x = y << 3" be faster than "x = y * 8" ? [...]
I was using a compiler in the '80s that was smart enough to replace * 8
with << 3. Stuff like this in the source just obscures the intent.
Explain how it obscures the intent.
obviously we are not on the same wavelength. If I want to multiply by 8
I write *8. Why would I do anything else? (unless measurement showed
<<3 was faster *and* this line of code needed to be faster).
If shifting by 3 is the *same* as multiplying by 8, then how is
shifting by 8 "doing something else" other than multiplying by 8? Tell
me, why do you think C includes a << operation?
What about *10 would you replace that with two shifts and an add?
That's a different question. Doing so involves a dependency chain of
operations, and there are alternative platform specific tricks for
this. So it doesn't belong in the "beginners section".
--
Paul Hsieh
http://www.pobox.com/~qed/
http://bstring.sf.net/
.
- Follow-Ups:
- Re: The performance of all kinds of C operations
- From: Ian Collins
- Re: The performance of all kinds of C operations
- From: Keith Thompson
- Re: The performance of all kinds of C operations
- References:
- Re: The performance of all kinds of C operations
- From: Ronald Bruck
- Re: The performance of all kinds of C operations
- From: Tim Prince
- Re: The performance of all kinds of C operations
- From: Roberto Waltman
- Re: The performance of all kinds of C operations
- From: spibou
- Re: The performance of all kinds of C operations
- From: websnarf
- Re: The performance of all kinds of C operations
- From: Eric Sosman
- Re: The performance of all kinds of C operations
- From: websnarf
- Re: The performance of all kinds of C operations
- From: Nick Keighley
- Re: The performance of all kinds of C operations
- From: websnarf
- Re: The performance of all kinds of C operations
- From: Nick Keighley
- Re: The performance of all kinds of C operations
- Prev by Date: Re: wit's end
- Next by Date: Re: Using static to init vars?
- Previous by thread: Re: The performance of all kinds of C operations
- Next by thread: Re: The performance of all kinds of C operations
- Index(es):
Relevant Pages
|