Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "FP precision conv" with no doubles in sight




On 30 Oct 2004, at 00:59, James W. Walker wrote:

Shark is showing "FP precision conv" on a line:

m_Center=getPosition()+0.5f*getSize();

Here m_Center, getPosition(), and getSize() are vector objects, each containing 3 floats. There are operators defining addition of two vectors and multiplication of a scalar and a vector.

Terminology check: You don't mean vectors as in wide types used for altivec. Do you? You mean a C++ class which holds a mathematical vector of 3 floating point values x, y & z. All single precision floats. Operators defined using operator overloading.


Vector is a very overloaded term at the best of times. On a PPC performance mailing list it gets another definition.

For what it's worth, the assembly lines identified as corresponding to that source line are...

// We've missed a load of f0 from 4(r28) (Origin.X) and loads of f2-4
lfs      f1,8(r28)	// f1 loaded (Origin.Y)
fsubs    f5,f3,f0	// f5 = f3 - f0
lfs      f0,12(r28)	// f0 loaded (Origin.Z)
fsubs    f2,f2,f1	// f2 = f2 - f1
fsubs    f4,f4,f0	// f4 = f4 - f0

stfs     f5,16(r28)	// store f5 (Size.X)
stfs     f2,20(r28)	// store f2 (Size.Y)
stfs     f4,24(r28)	// store f4 (Size.Z)

frsp     f0,f5		// round f5 into f0
frsp     f1,f2		// round f2 into f1
frsp     f2,f4		// round f4 into f2

lfs f3,-9580(r2) // f3 loaded - suspect this is 0.5f

fmuls    f5,f3,f0	// f5 = f3 * f0 (Size.X / 2)
fmuls    f4,f3,f1	// f4 = f3 * f1 (Size.Y / 2)
fmuls    f3,f3,f2	// f3 = f3 * f2 (Size.Z / 2)

lfs      f0,4(r28)	// f0 loaded (Origin.X)
lfs      f1,8(r28)	// f1 loaded (Origin.Y)
lfs      f2,12(r28)	// f2 loaded (Origin.Z)

fadds    f5,f0,f5	// f5 = f0 + f5 (Size.X / 2 + Origin.X)
fadds    f1,f1,f4	// f1 = f1 + f4 (Size.Y / 2 + Origin.Y)
fadds    f0,f2,f3	// f0 = f2 + f3 (Size.Z / 2 + Origin.Z)

stfs     f5,28(r28)	// store f5 (m_Center.X)
stfs     f1,32(r28)	// store f1 (m_Center.Y)
stfs     f0,36(r28)	// store f0 (m_Center.Z)

Forgive my annotations and reordering. I find I have to d0 that to work out what's going on. It looks like you're result from getSize() is being stored in your class before being returned. I don't know why it should, but I wonder if that's getting the compiler confused and it thinks it has to round it to ensure single precision after that.


It's the only thing that looks odd to me.

Paul

Attachment: PGP.sig
Description: This is a digitally signed message part

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
PerfOptimization-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/perfoptimization-dev/email@hidden

This email sent to email@hidden

References: 
 >"FP precision conv" with no floats in sight (From: "James W. Walker" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.