Re: Operation recomputation
- From: "Nils O. Selåsdal" <NOS@xxxxxxx>
- Date: Fri, 01 Sep 2006 07:21:50 +0200
Michel Rouzic wrote:
Nils O. Selåsdal wrote:Michel Rouzic wrote:Barry Schwarz wrote:Perhaps. But don't go turning every rock for potentialOn 31 Aug 2006 20:04:02 -0700, "Michel Rouzic" <Michel0528@xxxxxxxx>so, in case of a doubt, I should do the storage of the result myself,
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.
like, make a variable to replace each recurrent operation?
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 ;-)
Don't presume.
Profile first, then optimize.
.
- Follow-Ups:
- Re: Operation recomputation
- From: Michel Rouzic
- 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"
- Re: Operation recomputation
- From: Michel Rouzic
- Operation recomputation
- Prev by Date: Re: Operation recomputation
- Next by Date: Re: Operation recomputation
- Previous by thread: Re: Operation recomputation
- Next by thread: Re: Operation recomputation
- Index(es):
Relevant Pages
|