Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Richard Henderson <richard@atheist.tamu.edu>
Subject: Re: compiler efficency
Date: Mon, 27 Jan 1997 17:35:57 -0600 (CST)	[thread overview]
Message-ID: <199701272335.RAA26615@atheist.tamu.edu> (raw)
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

  parent reply	other threads:[~1997-01-27 23:35 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-27 20:37 compiler efficency Claus Denk
1997-01-27 20:35 ` Brett McCormick
1997-01-27 20:37 ` Lev D Gelb
1997-01-27 21:15 ` Jim Nance
1997-01-27 22:13 ` Scott Locklin
1997-01-27 22:41 ` Michal Jaegermann
1997-01-27 23:35 ` Richard Henderson [this message]
  -- strict thread matches above, loose matches on Subject: below --
1997-01-27 20:51 Robert Williams
1997-01-27 21:48 Toon Moene
1997-01-27 22:15 Przemek Klosowski
1997-01-27 22:41 Craig Burley
1997-01-28 11:22 Claus Denk
1997-01-28 20:02 Toon Moene
1997-01-28 23:23 Huw Davies
     [not found] <9701282002.AA15294@moene.indiv.nluug.nl>
1997-01-29  0:10 ` Michal Jaegermann
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox