Re: Operation recomputation
- From: "Michel Rouzic" <Michel0528@xxxxxxxx>
- Date: 31 Aug 2006 22:18:01 -0700
Nils O. Selåsdal wrote:
Michel Rouzic wrote:
Barry Schwarz wrote:
On 31 Aug 2006 20:04:02 -0700, "Michel Rouzic" <Michel0528@xxxxxxxx>
wrote:
Hi,The answer depends on whether your compiler can recognize the common
I'd like to know whether an operation which always has the same result
will be recomputed. Here's the context : I in a loop have to compare
many things to foo>>1 in an if statement. In that very if statement I
compare stuff with (foo>>1) about four times, and I'd like to know if
it everytime does the shifting from the original foo value or if it
re-uses the previous result, since the value of foo did not change.
Also I use many times in my loop (bar>>1), same question with it, does
it get calculated over again or not?
sub-expression and the fact that the values have not changed. Some
compilers have options that say optimize for speed or optimize for
space. The language spec does not address the issue.
All in all a quality of implementation issue.
so, in case of a doubt, I should do the storage of the result myself,
like, make a variable to replace each recurrent operation?
Perhaps. But don't go turning every rock for potential
microoptimizations like this.
in my case it's not a micro optimization (I guess) since for my
(foo>>1) example, I use that 10 times for each pixel I process, and
since I can have up to 6 million pixels to process every second..
that's 60 million shifts a second I can avoid, I presume. Considered
that I'm going to run this code on a 200 MHz ARM920T, it might not be a
micro optimization at all ;-)
.
- Follow-Ups:
- Re: Operation recomputation
- From: "Nils O. Selåsdal"
- Re: Operation recomputation
- References:
- Operation recomputation
- From: Michel Rouzic
- Re: Operation recomputation
- From: Barry Schwarz
- Re: Operation recomputation
- From: Michel Rouzic
- Re: Operation recomputation
- From: "Nils O. Selåsdal"
- Operation recomputation
- Prev by Date: Re: Convert 00010000 to 11110000......how?
- Next by Date: Re: Operation recomputation
- Previous by thread: Re: Operation recomputation
- Next by thread: Re: Operation recomputation
- Index(es):
Relevant Pages
|