Mail Archives: pgcc/1999/05/10/18:37:21
On Mon, 10 May 1999, Marc Lehmann wrote:
>On Mon, May 10, 1999 at 12:50:56AM -0700, David Whysong wrote:
>>
>> My question is, how well does the compiler optimize code that looks like
>> this:
>
>How about if you benchmark it? ;)
I've been trying to do that all morning.
>In theory, it should get rid of most if not all common subexpressions
>automatically, however, the x86 does not have much fp registers to store the
>intermediate values...
Theory doesn't seem to fit the data very well then. :-) I have gained
nearly a factor of two in speed after doing some CSE by hand. Even on the
simple code fragment I posted, a little "hand optimizing" significantly
reduced the number of fmul ops. As far as I can see, very little or no CSE
was being done at all.
>> Can I do anything so that the compiler produces a faster binary?
>
>You could try out -fschedule-insns, which improves floating point
>scheduling unless you have high register pressure. You should benchmark
>it. In general you should play around with the switches a bit (-mno-ieee
>often helps while improving the accuracy as well).
I'll try it.
>The only other option is to try some algebraic simplifications that the
>compiler doesn't do (Ibecause its too dumb) or that the compiler is not
>allowed to do in C (use fortran instead).
Thanks,
Dave
David Whysong dwhysong AT physics DOT ucsb DOT edu
Astrophysics graduate student University of California, Santa Barbara
My public PGP keys are on my web page - http://www.physics.ucsb.edu/~dwhysong
DSS PGP Key 0x903F5BD6 : FE78 91FE 4508 106F 7C88 1706 B792 6995 903F 5BD6
D-H PGP key 0x5DAB0F91 : BC33 0F36 FCCD E72C 441F 663A 72ED 7FB7 5DAB 0F91
- Raw text -