This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


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

Re: A bug in IA32 assembler


On Thu, Jun 28, 2001 at 11:03:03PM -0700, Richard Henderson wrote:
> On Thu, Jun 28, 2001 at 07:03:30PM -0700, H . J . Lu wrote:
> > Have you tried it on the testcase I enclosed? It doesn't work for me.
> 
> No.  At least in the message I saw the test case was not
> complete.  Perhaps I've already deleted the original.

I am enclosing it again. Try to compile and run it on a P/III
machine.

> 
> In either case, I _guarantee_ that the asm I quoted is wrong,
> even if the replacement I suggested isn't right.
> 
> 

This one:

        asm("movaps (%0),%%xmm0"                                //SSE
        :
        :"g"(A));

generates

	movaps ($A.0), %xmm0

But this one

        asm("movaps %%xmm0,(%0)":"=g"(C));                        //SSE

generates

	movaps %xmm0,(C.2)

What is the correct way to get the working binary?


H.J.
-----
/* test program for SSE by kaz @ kobe1995.net
        % cc -g bug.c && ./a.out
  But it fails. So,
        % cc -g -S bug.c
  And change bug.s to avoid bug of gcc (may be):
         #APP
        -       movaps ($A.15),%xmm0
        -       movaps ($B.16),%xmm1
        +       movaps A.15,%xmm0
        +       movaps B.16,%xmm1
         #NO_APP
        % c++ loop.s && ./a.out
*/

#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include <stdlib.h>
#include <limits.h>

main(){
static float __attribute__((aligned(16)))
        A[4]={1.,1.,1.,1.},
        B[4]={0.,1.,2.,3.},
        C[4];

        int i;

        printf("float A=(");
        for(i=0;i<4;i++)        printf("%f,",A[i]);
        printf("\b)\n");

        printf("float B=(");
        for(i=0;i<4;i++)        printf("%f,",B[i]);
        printf("\b)\n");

        asm("movaps (%0),%%xmm0"                                //SSE
        :
        :"g"(A));
        asm("movaps (%0),%%xmm1"                                //SSE
        :
        :"g"(B));

        asm("addps %xmm1,%xmm0");                               //SSE
//      asm("mulps %xmm1,%xmm0");                               //SSE
        asm("movaps %%xmm0,(%0)":"=g"(C));                        //SSE
        printf("float C=(");
        for(i=0;i<4;i++)        printf("%f,",C[i]);
        printf("\b)\n");
}


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