This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [ASM] [PowerPC] floating-point registers mnemonics


On 01/14/2011 05:13 PM, Segher Boessenkool wrote:
On the code below, I'm storing the result of the product in a temporary
variable (fra).

inline void MTH_Vec3Scale(register MTH_tt_Vector3 *D,register const
MTH_tt_Vector3 *A, register f32 f)
{
     register       f32  fra;
     asm     (       "lfs   %3,   0(%0)              \n"        // FRA<-
*A
                     "\t    fmul   %3,   %3,     %2  \n"       // FRT<-
FRA
* FRC
                     "\t    stfs   %3,   0(%1)       \n"         // *dest =
FRT

                     "\t    lfs    %3,   4(%0)       \n"
                     "\t    fmul   %3,   %3,     %2  \n"
                     "\t    stfs   %3,   4(%1)       \n"

                     "\t    lfs    %3,   8(%0)       \n"
                     "\t    fmul   %3,   %3,     %2  \n"
                     "\t    stfs   %3,   8(%1)       \n"
         /* outputs: */ :
         /* inputs : */ :"b"(A),"b"(D),"f"(f),"f"(fra)
         /* clobbers:*/ :"memory");
}

You write to "fra" (and never read it), so you should list it in outputs instead of in inputs:

/* outputs: */ :"=f"(fra)

Make that an earlyclobber: "=&f"


Andrew.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]