g77 performance for real*complex
Tim Prince
tprince@computer.org
Thu Aug 3 09:37:00 GMT 2000
However, I find that both g77-2.95.2 and the 200000801 snapshot, when compiled at -Os for i686, with a COMMON declaration added to
avoid optimizing away all the code, are simplifying the generated code down to the 2 multiplications. So I don't see how this can be
considered a bug.
common z2
real*8 x
complex*16 z1, z2
x = 1.1d0
18: dd 05 10 00 00 00 fldl 0x10
1e: 55 push %ebp
z1 = (2.2d0, 3.3d0)
z2 = x*z1
1f: dd 05 00 00 00 00 fldl 0x0
25: 89 e5 mov %esp,%ebp
27: d8 c9 fmul %st(1),%st
29: d9 c9 fxch %st(1)
2b: 83 ec 08 sub $0x8,%esp
2e: dc 0d 08 00 00 00 fmull 0x8
34: d9 c9 fxch %st(1)
36: b8 00 00 00 00 mov $0x0,%eax
end
3b: 83 c4 f8 add $0xfffffff8,%esp
3e: dd 1d 00 00 00 00 fstpl 0x0
44: dd 58 08 fstpl 0x8(%eax)
Tim Prince
----- Original Message -----
From: "Tim Prince" <tprince@computer.org>
To: "June-Yub Lee" <jylee@math.ewha.ac.kr>; <gcc-bugs@gcc.gnu.org>
Sent: Thursday, August 03, 2000 7:07 AM
Subject: Re: g77 performance for real*complex
> I think this is the expectation with most compilers, that promotion to complex occurs before multiplication. You have the option
to
> write it out the more efficient way in source. Certainly, the optimization you suggest could be valuable, but g77 doesn't have
the
> resources available to incorporate such features, and it is never sold by benchmarking.
>
> Tim Prince
> ----- Original Message -----
> From: "June-Yub Lee" <jylee@math.ewha.ac.kr>
> To: <gcc-bugs@gcc.gnu.org>
> Sent: Thursday, August 03, 2000 6:37 AM
> Subject: g77 performance for real*complex
>
>
> > Hello.
> > I really thank the developers of GNU fortran complier for their efferts.
> >
> > I usually perfer to use g77 instead of the genuin Fortran compiler
> > from the SUN microsystem for my Ultra-Sparc 450MHz machine.
> > I try to optimize my code to get best FLOPS in my codes
> > and the g77 generates faster codes in many cases.
> > One day, I found that my code was runing about 40% slower
> > than my expectaion so I tried to look at the assembly code.
> >
> > Maybe you alreay know that the problem of real*complex but
> > let me present a simplest example:
> > > cat t.f
> > real*8 x
> > complex*16 z1, z2
> > x = 1.1d0
> > z1 = (2.2d0, 3.3d0)
> > z2 = x*z1
> > end
> >
> > The program needs only TWO double precision multiplication (fmuld):
> > x*dble(z1) for the real part, x*dimag(z1) for the imaginary part.
> > However, the g77 (2.95.1) generates 2*fmuld & fsubd for the real part
> > and 2*fmuld & faddd for the imaginary part. And it comsumes 6 flops
> > for real*complex even under -O2 optimization mode.
> >
> > Here goes my complier version and I think I don't need to send you
> > my assembly code since it is easily reproducible. Would you tell me the
> > currect status of the compile regarding complex arithmetic performance?
> >
> > > g77 -v -S t.f
> > g77 version 2.95.1 19990816 (release) (from FSF-g77 version 0.5.25 19990816 (release))
> > Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.1/specs
> > gcc version 2.95.1 19990816 (release)
> > /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.1/f771 t.f -quiet -dumpbase t.f -version -fversion -o t.s
> > GNU F77 version 2.95.1 19990816 (release) (sparc-sun-solaris2.7) compiled by GNU C version 2.8.1.
> > GNU Fortran Front End version 0.5.25 19990816 (release)
> >
> >
> > Thank you very much.
> > Sincerely yours,
> > June-Yub Lee
>
More information about the Gcc-bugs
mailing list