From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <199701272335.RAA26615@atheist.tamu.edu> Date: Mon, 27 Jan 1997 17:35:57 -0600 (CST) From: Richard Henderson Subject: Re: compiler efficency In-Reply-To: <199701272037.VAA20864@servix.us.es> > (output of f2c): > for (i = 2; i <= i__1; ++i) { > gam += 1. / (doublereal) i; > } The cast is likely the problem. If you rewrite the loop like so: long i, i__1; double i__d, gam; for (i__d = i = 2; i <= i__1; ++i, ++i__d) { gam += 1. / i__d; } things go much faster. This is because in order to cast from integer to double, we must save the register to memory, load into an fp register, then do a cvtqt instruction. You can save all that by keeping a parallel loop counter as a double. Testing this hypothesis on an ev45/275, I get a 1.4 times speedup. Now, because of the nature of FP, it is not legal for GCC to to automatically do this conversion unless it can bound i__1 below 2**56 or something. But I bet it doesn't do anything under any circumstances, nor is it likely to in the future. I don't know what context this appeared in in the original Fortran source, but your best bet is to fix f2c to shadow the loop variable itself. r~ -- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com