This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: A bug in IA32 assembler
- To: Richard Henderson <rth at redhat dot com>
- Subject: Re: A bug in IA32 assembler
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Fri, 29 Jun 2001 00:15:56 -0700
- Cc: gcc at gcc dot gnu dot org, binutils at sourceware dot cygnus dot com
- References: <20010627234857.A23201@lucon.org> <20010628225833.Q4573@bubble.local> <20010628093749.B31850@lucon.org> <20010629102120.V4573@bubble.local> <20010628181154.A7899@lucon.org> <20010628185526.A16798@redhat.com> <20010628190330.A8724@lucon.org> <20010628230303.A16961@redhat.com>
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");
}