optimizing

Donald McLachlan don at dgbt.doc.ca
Wed Mar 13 02:45:18 AEST 1991


>
>From: rjohnson at shell.com (Roy Johnson)
>Newsgroups: comp.lang.c
>Subject: Re: Heroic constant folding (was micro-optimizing loops etc.)
>
>In article <1991Mar2.010049.21044 at grebyn.com> ckp at grebyn.com (Checkpoint Technologies) writes:
>>>Of course, the best optimization for:
>>>	for (i = 1; i < 100; i++)
>>>		x += i;
>>>is:
>>>	x += 4950;
>
>This doesn't look to be such a bad thing to optimize away (speaking
>with all the authority of one who doesn't write compilers).
>
>You "simply" check each loop to be sure that there are no function
>calls, and that all variables referenced in the loop are initialized
>there.  Then you can generate appropriate moves instead of a loop.

I would also recommend checking that those variables are not decalared
volatile. It is possible that another processor is watching the progression
of a variable through certain states (not likely under Unix, but C is
no limited to Unix:-).




More information about the Comp.lang.c mailing list