Hmmmm, yeah... I guess it shouldn't make an 8.5 time difference. You're right, it should be a smaller difference. The squaring is 2 muls and an add vs 4 muls and 2 adds, so it should be less than twice as fast when you include the other portion. The instruction ordering might be more optimal also. 8.5 times though... weird. Brian On 3/3/06, Greg Buchholz <greg@xxxxxxxxxxxxxxxxxxxx> wrote: > Brian Budge wrote: > > It may be that I'm missing something, but you appear to be computing > > different things... > > > > Zi = 2.0*Zr*Zi + Ci; > > Zr = Tr - Ti + Cr; > > > > vs > > > > Z = Z*Z + C; > > > > No doubt the 2.0 makes a difference... > > Hmm. I don't get what you are saying. Squaring a complex number > like a+ib you get... > > (a+ib) * (a+ib) > a*a + iab + iab - b*b > (a*a - b*b) + i2ab > > ...Are you saying a multiplication instead of an addition is the cause? > Yes, the C version is a little more optimized, but I was surprised at > the factor of 8.5 time difference for gcc-4.1pre021006. I guess I > expecting something small, say a 20-50% slowdown. And you get all of > the speed back if you just use "-ffast-math". Maybe I'm just surprised > that the optimizations that "-ffast-math" turns on do such a good job. > > Greg Buchholz > >