Complex arithmetic improvements?

Martin Kahlert martin.kahlert@mchp.siemens.de
Fri Aug 21 04:12:00 GMT 1998


Quoting Peter Chang (peter@eexpc.eee.nott.ac.uk):
> 
> Hello all,
> 
> I was writing code a while ago to implement complex arithmetic in C when I
> happened upon the gcc extension __complex__.
> 
> While it works fine, I looked at the egcs-1.03a source to see how it was
> done and found the methods in egcs-1.0.3a/gcc/optabs.c starting from line
> 1235. It seems to use rather naive methods to do things like multiply and
> divide: 
> 
> Line 1266: /* (a+ib) * (c+id) = (ac-bd) + i(ad+cb) */ 
> 
> this can be improved to
> 
>             = (ac - bd) + i[ (a+b)(c+d) - ac - bd ]
> 
> which is one multiply less but one addition and two subtractions more. 
> This is usually faster as multiply is quite slow. Figures, anyone? All I
> remember from my assembly programming days on a 68000 was that it was much
> slower.

One comment: My Pentium Pro seems to do a multiplication as fast as an
addition (about 2 cycles) So this improvement would be a regression
in that case.

Bye,
Martin.

-- 
Q: How does a UNIX Guru do Sex ?
A: unzip;strip;touch;finger;mount;fsck;more;yes;umount;sleep



More information about the Gcc mailing list