Put your code... (was Re: gotos

Dave Jones djones at megatest.UUCP
Thu May 5 08:08:50 AEST 1988


in article <211 at obie.UUCP>, wes at obie.UUCP (Barnacle Wes) says:
> 

...

> ...  "common subexpression removal."
> It is quite often used to optimize for space (less code space is
> required, obviously).  It would NOT commonly be used if you are
> looking for the utmost in speed, the time spent jumping into/out of
> the common code does not make for faster programs.
> -- 

Nope, that's not what "common subexpression removal" is.  Consider this
Pascal fragment:


	A[i].k := A[i].k + j;

The expression A[i].k occurs twice.  Furthermore, its "L-value", or
location, must evaluate to the same address when each subexpression is
evaluated.  So a clever compiler will only calculate the address of
A[i].k once, and will leave it in a register to be reused.  There is no 
"jumping into/out of the common code".  

In Pascal programs, this optimization will often increase speed by
thirty percent or more.  Depends on the program.


	-- Dave J.



More information about the Comp.lang.c mailing list