Path: utzoo!mnetor!uunet!husc6!purdue!decwrl!megatest!djones From: djones@megatest.UUCP (Dave Jones) Newsgroups: comp.lang.c Subject: Re: Put your code... (was Re: gotos Message-ID: <504@goofy.megatest.UUCP> Date: 4 May 88 22:08:50 GMT References: <211@obie.UUCP> Organization: Megatest Corporation, San Jose, Ca Lines: 29 in article <211@obie.UUCP>, wes@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.