Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-22 Thread Rainer Orth
Hi Daniel,

> On 09/22/2017 02:18 AM, Rainer Orth wrote:
>> Hi Daniel,
>>
>>> On 09/21/2017 05:18 PM, Daniel Santos wrote:
 So libgcc doesn't use a config.in. :(
>>> Scratch that, I forgot that we're using gcc/config.in via auto-host.h. 
>>> So I only have to add this to gcc/configure.ac and it will be available
>>> for my libgcc header -- this is what I used to sniff out support for the
>>> .hidden directive.
>> Please don't go that route: it's totally the wrong direction.  There's
>> work going on to further decouple libgcc from gcc-private headers and
>> configure results.  libgcc already has its own configure tests for
>> assembler features, and its own config.in.  What's wrong with adapting
>> libitm's avx test in libitm/acinclude.m4 (LIBITM_CHECK_AS_AVX) for
>> libgcc?  Should be trivial...
>>
>>  Rainer
>>
>
> Oops, I just saw your email after submitting my other patch.  Yes, I am
> mistaken about config.in, sorry about that.  I didn't see a config.h
> file, but examining further it looks like it outputs to auto-target.h. 
> Also, I was looking for some HAVE_AS* macros, but they are named
> differently.

Right: though some are for assembler features, the macros are named
differently.

> I had previously included gcc's auto-host.h since it was in the include
> path in order to use HAVE_AS_HIDDEN, so in order to decouple this I'll

HAVE_GAS_HIDDEN actually ;-)

> need to add that check into libgcc/configure.ac as well.  Again,
> shouldn't be that much code.  Sound sane to you?

You could do that, but it was already used before your patches, so
please separate it from the current issue if you go down that route.
libgcc is still full of cleanup possibilities :-)

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-22 Thread Daniel Santos
On 09/22/2017 02:18 AM, Rainer Orth wrote:
> Hi Daniel,
>
>> On 09/21/2017 05:18 PM, Daniel Santos wrote:
>>> So libgcc doesn't use a config.in. :(
>> Scratch that, I forgot that we're using gcc/config.in via auto-host.h. 
>> So I only have to add this to gcc/configure.ac and it will be available
>> for my libgcc header -- this is what I used to sniff out support for the
>> .hidden directive.
> Please don't go that route: it's totally the wrong direction.  There's
> work going on to further decouple libgcc from gcc-private headers and
> configure results.  libgcc already has its own configure tests for
> assembler features, and its own config.in.  What's wrong with adapting
> libitm's avx test in libitm/acinclude.m4 (LIBITM_CHECK_AS_AVX) for
> libgcc?  Should be trivial...
>
>   Rainer
>

Oops, I just saw your email after submitting my other patch.  Yes, I am
mistaken about config.in, sorry about that.  I didn't see a config.h
file, but examining further it looks like it outputs to auto-target.h. 
Also, I was looking for some HAVE_AS* macros, but they are named
differently.

I had previously included gcc's auto-host.h since it was in the include
path in order to use HAVE_AS_HIDDEN, so in order to decouple this I'll
need to add that check into libgcc/configure.ac as well.  Again,
shouldn't be that much code.  Sound sane to you?

Thanks,
Daniel


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-22 Thread Rainer Orth
Hi Daniel,

> On 09/21/2017 05:18 PM, Daniel Santos wrote:
>> So libgcc doesn't use a config.in. :(
>
> Scratch that, I forgot that we're using gcc/config.in via auto-host.h. 
> So I only have to add this to gcc/configure.ac and it will be available
> for my libgcc header -- this is what I used to sniff out support for the
> .hidden directive.

Please don't go that route: it's totally the wrong direction.  There's
work going on to further decouple libgcc from gcc-private headers and
configure results.  libgcc already has its own configure tests for
assembler features, and its own config.in.  What's wrong with adapting
libitm's avx test in libitm/acinclude.m4 (LIBITM_CHECK_AS_AVX) for
libgcc?  Should be trivial...

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-21 Thread Daniel Santos
On 09/21/2017 05:18 PM, Daniel Santos wrote:
> So libgcc doesn't use a config.in. :(

Scratch that, I forgot that we're using gcc/config.in via auto-host.h. 
So I only have to add this to gcc/configure.ac and it will be available
for my libgcc header -- this is what I used to sniff out support for the
.hidden directive.

I still wouldn't mind centralizing assembler sniffing in config/as.m4
(or similar) later on.

Thanks,
Daniel


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-21 Thread Daniel Santos
On 09/21/2017 11:14 AM, Rainer Orth wrote:
> Hi Daniel,
>
>> On 09/19/2017 01:58 AM, Jakub Jelinek wrote:
>>> What can be done in libgcc is detect in configure whether the assembler
>>> supports AVX, and if not, provide some alternative (e.g. because the insns
>>> are always the same, you could just code them as .byte or something 
>>> similar).
>>>
>>> Say like:
>>> --- i386-asm.h  2017-09-18 18:34:30.917126996 +0200
>>> +++ i386-asm.h  2017-09-19 08:56:58.829559038 +0200
>>> @@ -70,6 +70,7 @@ ASMNAME(fn):
>>>  #ifdef MS2SYSV_STUB_AVX
>>>  # define MS2SYSV_STUB_PREFIX __avx_
>>>  # define MOVAPS vmovaps
>>> +# define BYTE .byte
>>>  #elif defined(MS2SYSV_STUB_SSE)
>>>  # define MS2SYSV_STUB_PREFIX __sse_
>>>  # define MOVAPS movaps
>>> @@ -84,7 +85,8 @@ ASMNAME(fn):
>>> FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
>>>  
>>>  /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
>>> -# define SSE_SAVE \
>>> +# ifdef HAVE_AS_AVX
>> I'm not exactly an autotools expert, but libtim defines HAVE_AS_AVX from
>> libitm/acinclude.m4 -- of course I need it in libgcc.  Similarly, gcc
>> has a nice generic gcc_GAS_CHECK_FEATURE macro in gcc/acinclude.m4 which
>> it uses for all of its HAVE_AS_* macro tests defined in
>> gcc/configure.ac.  I can just copy, paste and edit what's in libitm, but
>> I find that rather distasteful.  Is there a cleaner way to do this?  Can
>> I suck gcc_GAS_CHECK_FEATURE and it's deps out of gcc/acinclude.m4 and
>> put it somewhere central, like config/as.m4?  The upside would be the
>> ability to make HAVE_AS_* macros in other sub-projects more uniform.
> This might be an option as a followup: less code duplication is
> certainly a good thing ;-)
>
>> Alternatively, I can just do the copy and paste and deal with it -- it's
>> not that much code. :)
> However, given that the above will take some time and testing and your
> patch has broken macOS bootstrap, I'd go this route now to unbreak the
> tree ASAP.
>
>   Rainer

A very good point!  So libgcc doesn't use a config.in. :(  So what about
committing my patch as is with HAVE_AS_AVX never defined and the avx
version of the stubs always being built via the .byte directives so that
the build is un-broken, and then figure out how (and where) to add
HAVE_AS_AVX afterwards?  I would still prefer to run a full bootstrap,
but updating an already build bootstrap is good and the tests should
hopefully be fixed on Solaris as well.

Thanks,
Daniel


diff --git a/gcc/testsuite/gcc.target/i386/pr82196-1.c b/gcc/testsuite/gcc.target/i386/pr82196-1.c
index ef858328f00..541d975480d 100644
--- a/gcc/testsuite/gcc.target/i386/pr82196-1.c
+++ b/gcc/testsuite/gcc.target/i386/pr82196-1.c
@@ -1,7 +1,7 @@
 /* { dg-do compile { target lp64 } } */
 /* { dg-options "-msse -mcall-ms2sysv-xlogues -O2" } */
-/* { dg-final { scan-assembler "call.*__sse_savms64_18" } } */
-/* { dg-final { scan-assembler "jmp.*__sse_resms64x_18" } } */
+/* { dg-final { scan-assembler "call.*__sse_savms64f?_12" } } */
+/* { dg-final { scan-assembler "jmp.*__sse_resms64f?x_12" } } */
 
 void __attribute__((sysv_abi)) a() {
 }
@@ -9,6 +9,5 @@ void __attribute__((sysv_abi)) a() {
 static void __attribute__((sysv_abi)) (*volatile a_noinfo)() = a;
 
 void __attribute__((ms_abi)) b() {
-  __asm__ __volatile__ ("" :::"rbx", "rbp", "r12", "r13", "r14", "r15");
   a_noinfo ();
 }
diff --git a/gcc/testsuite/gcc.target/i386/pr82196-2.c b/gcc/testsuite/gcc.target/i386/pr82196-2.c
index 8fe58411d5e..7166d068bc1 100644
--- a/gcc/testsuite/gcc.target/i386/pr82196-2.c
+++ b/gcc/testsuite/gcc.target/i386/pr82196-2.c
@@ -1,7 +1,7 @@
 /* { dg-do compile { target lp64 } } */
 /* { dg-options "-mavx -mcall-ms2sysv-xlogues -O2" } */
-/* { dg-final { scan-assembler "call.*__avx_savms64_18" } } */
-/* { dg-final { scan-assembler "jmp.*__avx_resms64x_18" } } */
+/* { dg-final { scan-assembler "call.*__avx_savms64f?_12" } } */
+/* { dg-final { scan-assembler "jmp.*__avx_resms64f?x_12" } } */
 
 void __attribute__((sysv_abi)) a() {
 }
@@ -9,6 +9,5 @@ void __attribute__((sysv_abi)) a() {
 static void __attribute__((sysv_abi)) (*volatile a_noinfo)() = a;
 
 void __attribute__((ms_abi)) b() {
-  __asm__ __volatile__ ("" :::"rbx", "rbp", "r12", "r13", "r14", "r15");
   a_noinfo ();
 }
diff --git a/libgcc/config/i386/i386-asm.h b/libgcc/config/i386/i386-asm.h
index 424e0f72aac..91e1c0123ff 100644
--- a/libgcc/config/i386/i386-asm.h
+++ b/libgcc/config/i386/i386-asm.h
@@ -69,13 +69,15 @@ ASMNAME(fn):
 
 #ifdef MS2SYSV_STUB_AVX
 # define MS2SYSV_STUB_PREFIX __avx_
-# define MOVAPS vmovaps
+# ifdef HAVE_AS_AVX
+#  define MOVAPS vmovaps
+# endif
 #elif defined(MS2SYSV_STUB_SSE)
 # define MS2SYSV_STUB_PREFIX __sse_
 # define MOVAPS movaps
 #endif
 
-#if defined (MS2SYSV_STUB_PREFIX) && defined (MOVAPS)
+#if defined (MS2SYSV_STUB_PREFIX)
 
 # define MS2SYSV_STUB_BEGIN(base_name) \
 	HIDDEN_FUNC(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
@@ -83,8 +85,10 @@ ASMNAME(fn):
 # define 

Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-21 Thread Rainer Orth
Hi Daniel,

> On 09/19/2017 01:58 AM, Jakub Jelinek wrote:
>> What can be done in libgcc is detect in configure whether the assembler
>> supports AVX, and if not, provide some alternative (e.g. because the insns
>> are always the same, you could just code them as .byte or something similar).
>>
>> Say like:
>> --- i386-asm.h   2017-09-18 18:34:30.917126996 +0200
>> +++ i386-asm.h   2017-09-19 08:56:58.829559038 +0200
>> @@ -70,6 +70,7 @@ ASMNAME(fn):
>>  #ifdef MS2SYSV_STUB_AVX
>>  # define MS2SYSV_STUB_PREFIX __avx_
>>  # define MOVAPS vmovaps
>> +# define BYTE .byte
>>  #elif defined(MS2SYSV_STUB_SSE)
>>  # define MS2SYSV_STUB_PREFIX __sse_
>>  # define MOVAPS movaps
>> @@ -84,7 +85,8 @@ ASMNAME(fn):
>>  FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
>>  
>>  /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
>> -# define SSE_SAVE  \
>> +# ifdef HAVE_AS_AVX
>
> I'm not exactly an autotools expert, but libtim defines HAVE_AS_AVX from
> libitm/acinclude.m4 -- of course I need it in libgcc.  Similarly, gcc
> has a nice generic gcc_GAS_CHECK_FEATURE macro in gcc/acinclude.m4 which
> it uses for all of its HAVE_AS_* macro tests defined in
> gcc/configure.ac.  I can just copy, paste and edit what's in libitm, but
> I find that rather distasteful.  Is there a cleaner way to do this?  Can
> I suck gcc_GAS_CHECK_FEATURE and it's deps out of gcc/acinclude.m4 and
> put it somewhere central, like config/as.m4?  The upside would be the
> ability to make HAVE_AS_* macros in other sub-projects more uniform.

This might be an option as a followup: less code duplication is
certainly a good thing ;-)

> Alternatively, I can just do the copy and paste and deal with it -- it's
> not that much code. :)

However, given that the above will take some time and testing and your
patch has broken macOS bootstrap, I'd go this route now to unbreak the
tree ASAP.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-21 Thread Uros Bizjak
On Thu, Sep 21, 2017 at 3:58 AM, Daniel Santos  wrote:
> On 09/19/2017 01:58 AM, Jakub Jelinek wrote:
>> What can be done in libgcc is detect in configure whether the assembler
>> supports AVX, and if not, provide some alternative (e.g. because the insns
>> are always the same, you could just code them as .byte or something similar).
>>
>> Say like:
>> --- i386-asm.h2017-09-18 18:34:30.917126996 +0200
>> +++ i386-asm.h2017-09-19 08:56:58.829559038 +0200
>> @@ -70,6 +70,7 @@ ASMNAME(fn):
>>  #ifdef MS2SYSV_STUB_AVX
>>  # define MS2SYSV_STUB_PREFIX __avx_
>>  # define MOVAPS vmovaps
>> +# define BYTE .byte
>>  #elif defined(MS2SYSV_STUB_SSE)
>>  # define MS2SYSV_STUB_PREFIX __sse_
>>  # define MOVAPS movaps
>> @@ -84,7 +85,8 @@ ASMNAME(fn):
>>   FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
>>
>>  /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
>> -# define SSE_SAVE   \
>> +# ifdef HAVE_AS_AVX
>
> I'm not exactly an autotools expert, but libtim defines HAVE_AS_AVX from
> libitm/acinclude.m4 -- of course I need it in libgcc.  Similarly, gcc
> has a nice generic gcc_GAS_CHECK_FEATURE macro in gcc/acinclude.m4 which
> it uses for all of its HAVE_AS_* macro tests defined in
> gcc/configure.ac.  I can just copy, paste and edit what's in libitm, but
> I find that rather distasteful.  Is there a cleaner way to do this?  Can
> I suck gcc_GAS_CHECK_FEATURE and it's deps out of gcc/acinclude.m4 and
> put it somewhere central, like config/as.m4?  The upside would be the
> ability to make HAVE_AS_* macros in other sub-projects more uniform.
>
> Alternatively, I can just do the copy and paste and deal with it -- it's
> not that much code. :)
>
> Also, is there any sense in doing this same check for SSE support in the
> assembler?  It's been out for 18 years now.

binutils 2.13.1 are required to buld the compiler on i?86-*-linux*, so
I guess SSE support is assumed.

Uros.


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-20 Thread Daniel Santos
On 09/19/2017 01:58 AM, Jakub Jelinek wrote:
> What can be done in libgcc is detect in configure whether the assembler
> supports AVX, and if not, provide some alternative (e.g. because the insns
> are always the same, you could just code them as .byte or something similar).
>
> Say like:
> --- i386-asm.h2017-09-18 18:34:30.917126996 +0200
> +++ i386-asm.h2017-09-19 08:56:58.829559038 +0200
> @@ -70,6 +70,7 @@ ASMNAME(fn):
>  #ifdef MS2SYSV_STUB_AVX
>  # define MS2SYSV_STUB_PREFIX __avx_
>  # define MOVAPS vmovaps
> +# define BYTE .byte
>  #elif defined(MS2SYSV_STUB_SSE)
>  # define MS2SYSV_STUB_PREFIX __sse_
>  # define MOVAPS movaps
> @@ -84,7 +85,8 @@ ASMNAME(fn):
>   FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
>  
>  /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
> -# define SSE_SAVE   \
> +# ifdef HAVE_AS_AVX

I'm not exactly an autotools expert, but libtim defines HAVE_AS_AVX from
libitm/acinclude.m4 -- of course I need it in libgcc.  Similarly, gcc
has a nice generic gcc_GAS_CHECK_FEATURE macro in gcc/acinclude.m4 which
it uses for all of its HAVE_AS_* macro tests defined in
gcc/configure.ac.  I can just copy, paste and edit what's in libitm, but
I find that rather distasteful.  Is there a cleaner way to do this?  Can
I suck gcc_GAS_CHECK_FEATURE and it's deps out of gcc/acinclude.m4 and
put it somewhere central, like config/as.m4?  The upside would be the
ability to make HAVE_AS_* macros in other sub-projects more uniform.

Alternatively, I can just do the copy and paste and deal with it -- it's
not that much code. :)

Also, is there any sense in doing this same check for SSE support in the
assembler?  It's been out for 18 years now.

Thanks,
Daniel



Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-19 Thread Daniel Santos
On 09/19/2017 07:13 AM, Rainer Orth wrote:
> Daniel Santos  writes:
>
>> On 09/17/2017 10:53 AM, Uros Bizjak wrote:
>>> OK.
>>>
>>> Thanks,
>>> Uros.
>> Thanks. I should have posted this Friday when my tests finished, but
>> I'll be committing with one minor change so tests don't run on m32 or mx32:
>>
>> --- a/gcc/testsuite/gcc.target/i386/pr82196-1.c
>> +++ b/gcc/testsuite/gcc.target/i386/pr82196-1.c
>> @@ -1,4 +1,4 @@
>> -/* { dg-do compile } */
>> +/* { dg-do compile { target lp64 } } */
>>  /* { dg-options "-msse -mcall-ms2sysv-xlogues -O2" } */
>>  /* { dg-final { scan-assembler "call.*__sse_savms64_18" } } */
>>  /* { dg-final { scan-assembler "jmp.*__sse_resms64x_18" } } */
>> diff --git a/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> b/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> index 31705bee29b..8fe58411d5e 100644
>> --- a/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> +++ b/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> @@ -1,4 +1,4 @@
>> -/* { dg-do compile } */
>> +/* { dg-do compile { target lp64 } } */
>>  /* { dg-options "-mavx -mcall-ms2sysv-xlogues -O2" } */
>>  /* { dg-final { scan-assembler "call.*__avx_savms64_18" } } */
>>  /* { dg-final { scan-assembler "jmp.*__avx_resms64x_18" } } */
>>
>> Other than that, full regression tests pass.
> However, they do FAIL on 64-bit Solaris/x86:
>
> +FAIL: gcc.target/i386/pr82196-1.c (test for excess errors)
>
> Excess errors:
> /vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.target/i386/pr82196-1.c:14:1: 
> error: bp cannot be used in asm here
>
> +UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler call.*__sse_savms64_18
> +UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler jmp.*__sse_resms64x_18
> +FAIL: gcc.target/i386/pr82196-2.c (test for excess errors)
> +UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler call.*__avx_savms64_18
> +UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler jmp.*__avx_resms64x_18
>
>   Rainer

Sorry about that, I forgot about Solaris' default enabled frame
pointers.  I don't even need a test this complicated, I'll make it much
simpler.

Thanks,
Daniel


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-19 Thread Daniel Santos
On 09/19/2017 01:58 AM, Jakub Jelinek wrote:
> On Mon, Sep 18, 2017 at 06:10:29PM -0500, Daniel Santos wrote:
>> Mike, can you take a look at this please?
>>
>> On 09/18/2017 10:17 AM, Dominique d'Humières wrote:
>>> This patch (r252896) breaks bootstrap on x86_64-apple-darwin10 configured 
>>> with
>>>
>>> ../work/configure --prefix=/opt/gcc/gcc8w 
>>> --enable-languages=c,c++,fortran,objc,obj-c++,ada,lto 
>>> --with-gmp=/opt/mp-new --with-system-zlib --with-isl=/opt/mp-new 
>>> --enable-lto --enable-plugin
>>>
>>> /opt/gcc/build_w/./gcc/xgcc -B/opt/gcc/build_w/./gcc/ 
>>> -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/bin/ 
>>> -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/lib/ -isystem 
>>> /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/include -isystem 
>>> /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/sys-include-g -O2 -O2  -g -O2 
>>> -DIN_GCC-W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format 
>>> -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem 
>>> ./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 
>>> -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe 
>>> -fno-common -I. -I. -I../.././gcc -I../../../work/libgcc 
>>> -I../../../work/libgcc/. -I../../../work/libgcc/../gcc 
>>> -I../../../work/libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -o 
>>> avx_savms64_s.o -MT avx_savms64_s.o -MD -MP -MF avx_savms64_s.dep -DSHARED 
>>> -c -xassembler-with-cpp ../../../work/libgcc/config/i386/avx_savms64.S
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>>> %xmm15,-0x30(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>>> %xmm14,-0x20(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>>> %xmm13,-0x10(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>>> %xmm12, (%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>>> %xmm11, 0x10(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>>> %xmm10, 0x20(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>>> %xmm9, 0x30(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>>> %xmm8, 0x40(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>>> %xmm7, 0x50(%rax)'
>>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>>> %xmm6, 0x60(%rax)'
>>> make[3]: *** [avx_savms64_s.o] Error 1
>>>
>>> Dominique
>> Thanks for the report.  AVX has been out since early 2011 and Wikipedia
>> claims that AVX support was added to OSX in version 10.6.8 in June 2011
>> and you seem to be using 10.8.0.  I would presume that also means that
>> the assembler supports it.  So I'm going to guess that it's the
>> "-mmacosx-version-min=10.5" parameter.  Can you please try setting that
>> to 10.6.8 and let me know the result?  I don't know what the minimum
>> system requirements for GCC 8 are going to be, but if it includes these
>> older versions of OSX then I'll have to figure out how to cope with it
>> in the libgcc build.
> What can be done in libgcc is detect in configure whether the assembler
> supports AVX, and if not, provide some alternative (e.g. because the insns
> are always the same, you could just code them as .byte or something similar).
>
> Say like:
> --- i386-asm.h2017-09-18 18:34:30.917126996 +0200
> +++ i386-asm.h2017-09-19 08:56:58.829559038 +0200
> @@ -70,6 +70,7 @@ ASMNAME(fn):
>  #ifdef MS2SYSV_STUB_AVX
>  # define MS2SYSV_STUB_PREFIX __avx_
>  # define MOVAPS vmovaps
> +# define BYTE .byte
>  #elif defined(MS2SYSV_STUB_SSE)
>  # define MS2SYSV_STUB_PREFIX __sse_
>  # define MOVAPS movaps
> @@ -84,7 +85,8 @@ ASMNAME(fn):
>   FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
>  
>  /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
> -# define SSE_SAVE   \
> +# ifdef HAVE_AS_AVX
> +#  define SSE_SAVE  \
>   MOVAPS %xmm15,-0x30(%rax); \
>   MOVAPS %xmm14,-0x20(%rax); \
>   MOVAPS %xmm13,-0x10(%rax); \
> @@ -95,6 +97,21 @@ ASMNAME(fn):
>   MOVAPS %xmm8,  0x40(%rax); \
>   MOVAPS %xmm7,  0x50(%rax); \
>   MOVAPS %xmm6,  0x60(%rax)
> +# else
> +/* If the assembler doesn't have AVX support, emit machine code for
> +   the above directly.  */
> +#  define SSE_SAVE  \
> + BYTE 0x44, 0x0f, 0x29, 0x78, 0xd0; \
> + BYTE 0x44, 0x0f, 0x29, 0x70, 0xe0; \
> + BYTE 0x44, 0x0f, 0x29, 0x68, 0xf0; \
> + BYTE 0x44, 0x0f, 0x29, 0x20;   \
> + BYTE 0x44, 0x0f, 0x29, 0x58, 0x10; \
> + BYTE 0x44, 0x0f, 0x29, 0x50, 0x20; \
> + BYTE 0x44, 0x0f, 0x29, 0x48, 0x30; \
> + BYTE 0x44, 0x0f, 0x29, 0x40, 0x40; \
> + BYTE 0x0f, 0x29, 0x78, 0x50;   \
> + BYTE 0x0f, 0x29, 0x70, 0x60
> +# endif
>  
>  /* Restore SSE registers 6-15. off is the 

Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-19 Thread Rainer Orth
Uros Bizjak  writes:

>> However, they do FAIL on 64-bit Solaris/x86:
>>
>> +FAIL: gcc.target/i386/pr82196-1.c (test for excess errors)
>>
>> Excess errors:
>> /vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.target/i386/pr82196-1.c:14:1:
>> error: bp cannot be used in asm here
>>
>> +UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler 
>> call.*__sse_savms64_18
>> +UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler 
>> jmp.*__sse_resms64x_18
>> +FAIL: gcc.target/i386/pr82196-2.c (test for excess errors)
>> +UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler 
>> call.*__avx_savms64_18
>> +UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler 
>> jmp.*__avx_resms64x_18
>
> Does the test compile with -fomit-frame-pointer?

It does indeed, and the patterns are present as expected.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-19 Thread Uros Bizjak
On Tue, Sep 19, 2017 at 2:13 PM, Rainer Orth
 wrote:
> Daniel Santos  writes:
>
>> On 09/17/2017 10:53 AM, Uros Bizjak wrote:
>>> OK.
>>>
>>> Thanks,
>>> Uros.
>>
>> Thanks. I should have posted this Friday when my tests finished, but
>> I'll be committing with one minor change so tests don't run on m32 or mx32:
>>
>> --- a/gcc/testsuite/gcc.target/i386/pr82196-1.c
>> +++ b/gcc/testsuite/gcc.target/i386/pr82196-1.c
>> @@ -1,4 +1,4 @@
>> -/* { dg-do compile } */
>> +/* { dg-do compile { target lp64 } } */
>>  /* { dg-options "-msse -mcall-ms2sysv-xlogues -O2" } */
>>  /* { dg-final { scan-assembler "call.*__sse_savms64_18" } } */
>>  /* { dg-final { scan-assembler "jmp.*__sse_resms64x_18" } } */
>> diff --git a/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> b/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> index 31705bee29b..8fe58411d5e 100644
>> --- a/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> +++ b/gcc/testsuite/gcc.target/i386/pr82196-2.c
>> @@ -1,4 +1,4 @@
>> -/* { dg-do compile } */
>> +/* { dg-do compile { target lp64 } } */
>>  /* { dg-options "-mavx -mcall-ms2sysv-xlogues -O2" } */
>>  /* { dg-final { scan-assembler "call.*__avx_savms64_18" } } */
>>  /* { dg-final { scan-assembler "jmp.*__avx_resms64x_18" } } */
>>
>> Other than that, full regression tests pass.
>
> However, they do FAIL on 64-bit Solaris/x86:
>
> +FAIL: gcc.target/i386/pr82196-1.c (test for excess errors)
>
> Excess errors:
> /vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.target/i386/pr82196-1.c:14:1: 
> error: bp cannot be used in asm here
>
> +UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler call.*__sse_savms64_18
> +UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler jmp.*__sse_resms64x_18
> +FAIL: gcc.target/i386/pr82196-2.c (test for excess errors)
> +UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler call.*__avx_savms64_18
> +UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler jmp.*__avx_resms64x_18

Does the test compile with -fomit-frame-pointer?

Uros.


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-19 Thread Rainer Orth
Daniel Santos  writes:

> On 09/17/2017 10:53 AM, Uros Bizjak wrote:
>> OK.
>>
>> Thanks,
>> Uros.
>
> Thanks. I should have posted this Friday when my tests finished, but
> I'll be committing with one minor change so tests don't run on m32 or mx32:
>
> --- a/gcc/testsuite/gcc.target/i386/pr82196-1.c
> +++ b/gcc/testsuite/gcc.target/i386/pr82196-1.c
> @@ -1,4 +1,4 @@
> -/* { dg-do compile } */
> +/* { dg-do compile { target lp64 } } */
>  /* { dg-options "-msse -mcall-ms2sysv-xlogues -O2" } */
>  /* { dg-final { scan-assembler "call.*__sse_savms64_18" } } */
>  /* { dg-final { scan-assembler "jmp.*__sse_resms64x_18" } } */
> diff --git a/gcc/testsuite/gcc.target/i386/pr82196-2.c
> b/gcc/testsuite/gcc.target/i386/pr82196-2.c
> index 31705bee29b..8fe58411d5e 100644
> --- a/gcc/testsuite/gcc.target/i386/pr82196-2.c
> +++ b/gcc/testsuite/gcc.target/i386/pr82196-2.c
> @@ -1,4 +1,4 @@
> -/* { dg-do compile } */
> +/* { dg-do compile { target lp64 } } */
>  /* { dg-options "-mavx -mcall-ms2sysv-xlogues -O2" } */
>  /* { dg-final { scan-assembler "call.*__avx_savms64_18" } } */
>  /* { dg-final { scan-assembler "jmp.*__avx_resms64x_18" } } */
>
> Other than that, full regression tests pass.

However, they do FAIL on 64-bit Solaris/x86:

+FAIL: gcc.target/i386/pr82196-1.c (test for excess errors)

Excess errors:
/vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.target/i386/pr82196-1.c:14:1: 
error: bp cannot be used in asm here

+UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler call.*__sse_savms64_18
+UNRESOLVED: gcc.target/i386/pr82196-1.c scan-assembler jmp.*__sse_resms64x_18
+FAIL: gcc.target/i386/pr82196-2.c (test for excess errors)
+UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler call.*__avx_savms64_18
+UNRESOLVED: gcc.target/i386/pr82196-2.c scan-assembler jmp.*__avx_resms64x_18

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-19 Thread Jakub Jelinek
On Mon, Sep 18, 2017 at 06:10:29PM -0500, Daniel Santos wrote:
> Mike, can you take a look at this please?
> 
> On 09/18/2017 10:17 AM, Dominique d'Humières wrote:
> > This patch (r252896) breaks bootstrap on x86_64-apple-darwin10 configured 
> > with
> >
> > ../work/configure --prefix=/opt/gcc/gcc8w 
> > --enable-languages=c,c++,fortran,objc,obj-c++,ada,lto 
> > --with-gmp=/opt/mp-new --with-system-zlib --with-isl=/opt/mp-new 
> > --enable-lto --enable-plugin
> >
> > /opt/gcc/build_w/./gcc/xgcc -B/opt/gcc/build_w/./gcc/ 
> > -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/bin/ 
> > -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/lib/ -isystem 
> > /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/include -isystem 
> > /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/sys-include-g -O2 -O2  -g -O2 
> > -DIN_GCC-W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format 
> > -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem 
> > ./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 
> > -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe 
> > -fno-common -I. -I. -I../.././gcc -I../../../work/libgcc 
> > -I../../../work/libgcc/. -I../../../work/libgcc/../gcc 
> > -I../../../work/libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -o 
> > avx_savms64_s.o -MT avx_savms64_s.o -MD -MP -MF avx_savms64_s.dep -DSHARED 
> > -c -xassembler-with-cpp ../../../work/libgcc/config/i386/avx_savms64.S
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> > %xmm15,-0x30(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> > %xmm14,-0x20(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> > %xmm13,-0x10(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> > %xmm12, (%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> > %xmm11, 0x10(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> > %xmm10, 0x20(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> > %xmm9, 0x30(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> > %xmm8, 0x40(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> > %xmm7, 0x50(%rax)'
> > ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> > %xmm6, 0x60(%rax)'
> > make[3]: *** [avx_savms64_s.o] Error 1
> >
> > Dominique
> 
> Thanks for the report.  AVX has been out since early 2011 and Wikipedia
> claims that AVX support was added to OSX in version 10.6.8 in June 2011
> and you seem to be using 10.8.0.  I would presume that also means that
> the assembler supports it.  So I'm going to guess that it's the
> "-mmacosx-version-min=10.5" parameter.  Can you please try setting that
> to 10.6.8 and let me know the result?  I don't know what the minimum
> system requirements for GCC 8 are going to be, but if it includes these
> older versions of OSX then I'll have to figure out how to cope with it
> in the libgcc build.

What can be done in libgcc is detect in configure whether the assembler
supports AVX, and if not, provide some alternative (e.g. because the insns
are always the same, you could just code them as .byte or something similar).

Say like:
--- i386-asm.h  2017-09-18 18:34:30.917126996 +0200
+++ i386-asm.h  2017-09-19 08:56:58.829559038 +0200
@@ -70,6 +70,7 @@ ASMNAME(fn):
 #ifdef MS2SYSV_STUB_AVX
 # define MS2SYSV_STUB_PREFIX __avx_
 # define MOVAPS vmovaps
+# define BYTE .byte
 #elif defined(MS2SYSV_STUB_SSE)
 # define MS2SYSV_STUB_PREFIX __sse_
 # define MOVAPS movaps
@@ -84,7 +85,8 @@ ASMNAME(fn):
FUNC_END(PASTE2(MS2SYSV_STUB_PREFIX, base_name))
 
 /* Save SSE registers 6-15. off is the offset of rax to get to xmm6.  */
-# define SSE_SAVE \
+# ifdef HAVE_AS_AVX
+#  define SSE_SAVE\
MOVAPS %xmm15,-0x30(%rax); \
MOVAPS %xmm14,-0x20(%rax); \
MOVAPS %xmm13,-0x10(%rax); \
@@ -95,6 +97,21 @@ ASMNAME(fn):
MOVAPS %xmm8,  0x40(%rax); \
MOVAPS %xmm7,  0x50(%rax); \
MOVAPS %xmm6,  0x60(%rax)
+# else
+/* If the assembler doesn't have AVX support, emit machine code for
+   the above directly.  */
+#  define SSE_SAVE\
+   BYTE 0x44, 0x0f, 0x29, 0x78, 0xd0; \
+   BYTE 0x44, 0x0f, 0x29, 0x70, 0xe0; \
+   BYTE 0x44, 0x0f, 0x29, 0x68, 0xf0; \
+   BYTE 0x44, 0x0f, 0x29, 0x20;   \
+   BYTE 0x44, 0x0f, 0x29, 0x58, 0x10; \
+   BYTE 0x44, 0x0f, 0x29, 0x50, 0x20; \
+   BYTE 0x44, 0x0f, 0x29, 0x48, 0x30; \
+   BYTE 0x44, 0x0f, 0x29, 0x40, 0x40; \
+   BYTE 0x0f, 0x29, 0x78, 0x50;   \
+   BYTE 0x0f, 0x29, 0x70, 0x60
+# endif
 
 /* Restore SSE registers 6-15. off is the offset of rsi to get to xmm6.  */
 # define SSE_RESTORE   \


Jakub


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-19 Thread Uros Bizjak
On Tue, Sep 19, 2017 at 1:10 AM, Daniel Santos  wrote:
> Mike, can you take a look at this please?
>
> On 09/18/2017 10:17 AM, Dominique d'Humières wrote:
>> This patch (r252896) breaks bootstrap on x86_64-apple-darwin10 configured 
>> with
>>
>> ../work/configure --prefix=/opt/gcc/gcc8w 
>> --enable-languages=c,c++,fortran,objc,obj-c++,ada,lto --with-gmp=/opt/mp-new 
>> --with-system-zlib --with-isl=/opt/mp-new --enable-lto --enable-plugin
>>
>> /opt/gcc/build_w/./gcc/xgcc -B/opt/gcc/build_w/./gcc/ 
>> -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/bin/ 
>> -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/lib/ -isystem 
>> /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/include -isystem 
>> /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/sys-include-g -O2 -O2  -g -O2 
>> -DIN_GCC-W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format 
>> -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem 
>> ./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 
>> -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe 
>> -fno-common -I. -I. -I../.././gcc -I../../../work/libgcc 
>> -I../../../work/libgcc/. -I../../../work/libgcc/../gcc 
>> -I../../../work/libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -o 
>> avx_savms64_s.o -MT avx_savms64_s.o -MD -MP -MF avx_savms64_s.dep -DSHARED 
>> -c -xassembler-with-cpp ../../../work/libgcc/config/i386/avx_savms64.S
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>> %xmm15,-0x30(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>> %xmm14,-0x20(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>> %xmm13,-0x10(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>> %xmm12, (%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>> %xmm11, 0x10(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>> %xmm10, 0x20(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>> %xmm9, 0x30(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>> %xmm8, 0x40(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>> %xmm7, 0x50(%rax)'
>> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
>> %xmm6, 0x60(%rax)'
>> make[3]: *** [avx_savms64_s.o] Error 1
>>
>> Dominique
>
> Thanks for the report.  AVX has been out since early 2011 and Wikipedia
> claims that AVX support was added to OSX in version 10.6.8 in June 2011
> and you seem to be using 10.8.0.  I would presume that also means that
> the assembler supports it.  So I'm going to guess that it's the
> "-mmacosx-version-min=10.5" parameter.  Can you please try setting that
> to 10.6.8 and let me know the result?  I don't know what the minimum
> system requirements for GCC 8 are going to be, but if it includes these
> older versions of OSX then I'll have to figure out how to cope with it
> in the libgcc build.

Please look at how libitm handles this issue.

Uros.


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-18 Thread Daniel Santos
Mike, can you take a look at this please?

On 09/18/2017 10:17 AM, Dominique d'Humières wrote:
> This patch (r252896) breaks bootstrap on x86_64-apple-darwin10 configured with
>
> ../work/configure --prefix=/opt/gcc/gcc8w 
> --enable-languages=c,c++,fortran,objc,obj-c++,ada,lto --with-gmp=/opt/mp-new 
> --with-system-zlib --with-isl=/opt/mp-new --enable-lto --enable-plugin
>
> /opt/gcc/build_w/./gcc/xgcc -B/opt/gcc/build_w/./gcc/ 
> -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/bin/ 
> -B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/lib/ -isystem 
> /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/include -isystem 
> /opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/sys-include-g -O2 -O2  -g -O2 
> -DIN_GCC-W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format 
> -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem 
> ./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 
> -fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe 
> -fno-common -I. -I. -I../.././gcc -I../../../work/libgcc 
> -I../../../work/libgcc/. -I../../../work/libgcc/../gcc 
> -I../../../work/libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -o 
> avx_savms64_s.o -MT avx_savms64_s.o -MD -MP -MF avx_savms64_s.dep -DSHARED -c 
> -xassembler-with-cpp ../../../work/libgcc/config/i386/avx_savms64.S
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> %xmm15,-0x30(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> %xmm14,-0x20(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> %xmm13,-0x10(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> %xmm12, (%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> %xmm11, 0x10(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> %xmm10, 0x20(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> %xmm9, 0x30(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> %xmm8, 0x40(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> %xmm7, 0x50(%rax)'
> ../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
> %xmm6, 0x60(%rax)'
> make[3]: *** [avx_savms64_s.o] Error 1
>
> Dominique

Thanks for the report.  AVX has been out since early 2011 and Wikipedia
claims that AVX support was added to OSX in version 10.6.8 in June 2011
and you seem to be using 10.8.0.  I would presume that also means that
the assembler supports it.  So I'm going to guess that it's the
"-mmacosx-version-min=10.5" parameter.  Can you please try setting that
to 10.6.8 and let me know the result?  I don't know what the minimum
system requirements for GCC 8 are going to be, but if it includes these
older versions of OSX then I'll have to figure out how to cope with it
in the libgcc build.

Thanks,
Daniel


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-18 Thread Dominique d'Humières
This patch (r252896) breaks bootstrap on x86_64-apple-darwin10 configured with

../work/configure --prefix=/opt/gcc/gcc8w 
--enable-languages=c,c++,fortran,objc,obj-c++,ada,lto --with-gmp=/opt/mp-new 
--with-system-zlib --with-isl=/opt/mp-new --enable-lto --enable-plugin

/opt/gcc/build_w/./gcc/xgcc -B/opt/gcc/build_w/./gcc/ 
-B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/bin/ 
-B/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/lib/ -isystem 
/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/include -isystem 
/opt/gcc/gcc8w/x86_64-apple-darwin10.8.0/sys-include-g -O2 -O2  -g -O2 
-DIN_GCC-W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wno-format 
-Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem 
./include   -mmacosx-version-min=10.5 -pipe -fno-common -g -DIN_LIBGCC2 
-fbuilding-libgcc -fno-stack-protector   -mmacosx-version-min=10.5 -pipe 
-fno-common -I. -I. -I../.././gcc -I../../../work/libgcc 
-I../../../work/libgcc/. -I../../../work/libgcc/../gcc 
-I../../../work/libgcc/../include  -DHAVE_CC_TLS -DUSE_EMUTLS -o 
avx_savms64_s.o -MT avx_savms64_s.o -MD -MP -MF avx_savms64_s.dep -DSHARED -c 
-xassembler-with-cpp ../../../work/libgcc/config/i386/avx_savms64.S
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
%xmm15,-0x30(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
%xmm14,-0x20(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
%xmm13,-0x10(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
%xmm12, (%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
%xmm11, 0x10(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
%xmm10, 0x20(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
%xmm9, 0x30(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
%xmm8, 0x40(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
%xmm7, 0x50(%rax)'
../../../work/libgcc/config/i386/savms64.h:47:no such instruction: `vmovaps 
%xmm6, 0x60(%rax)'
make[3]: *** [avx_savms64_s.o] Error 1

Dominique



Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-17 Thread Daniel Santos
On 09/17/2017 10:53 AM, Uros Bizjak wrote:
> OK.
>
> Thanks,
> Uros.

Thanks. I should have posted this Friday when my tests finished, but
I'll be committing with one minor change so tests don't run on m32 or mx32:

--- a/gcc/testsuite/gcc.target/i386/pr82196-1.c
+++ b/gcc/testsuite/gcc.target/i386/pr82196-1.c
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target lp64 } } */
 /* { dg-options "-msse -mcall-ms2sysv-xlogues -O2" } */
 /* { dg-final { scan-assembler "call.*__sse_savms64_18" } } */
 /* { dg-final { scan-assembler "jmp.*__sse_resms64x_18" } } */
diff --git a/gcc/testsuite/gcc.target/i386/pr82196-2.c 
b/gcc/testsuite/gcc.target/i386/pr82196-2.c
index 31705bee29b..8fe58411d5e 100644
--- a/gcc/testsuite/gcc.target/i386/pr82196-2.c
+++ b/gcc/testsuite/gcc.target/i386/pr82196-2.c
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target lp64 } } */
 /* { dg-options "-mavx -mcall-ms2sysv-xlogues -O2" } */
 /* { dg-final { scan-assembler "call.*__avx_savms64_18" } } */
 /* { dg-final { scan-assembler "jmp.*__avx_resms64x_18" } } */

Other than that, full regression tests pass.

Thanks,
Daniel


Re: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-17 Thread Uros Bizjak
On Thu, Sep 14, 2017 at 6:03 AM, Daniel Santos  wrote:
> I made a silly mistake in libgcc by testing the cpp macro __AVX__ to
> determine rather to use movaps or vmovaps in the stubs.  This resulted
> in the stubs choice of instruction being decided by the machine flags
> when the compiler was built rather than those being supplied at the
> command line.  This patch splits stubs into separate sse and avx
> versions so that both are available.
>
> gcc:
> config/i386/i386.c: (xlogue_layout::STUB_NAME_MAX_LEN): Increase to 20
> bytes.
> (xlogue_layout::s_stub_names): Add an additional size-2 diminsion.
> (xlogue_layout::get_stub_name): Modify to select the appropairate sse
> and avx version of the stub.
>
> gcc/testsuite:
> gcc.target/i386/pr82196-1.c: New test.
> gcc.target/i386/pr82196-2.c: Likewise.
>
> libgcc:
> config/i386/i386-asm.h (PASTE2): New macro.
> (ASMNAME): Modify to use PASTE2.
> (MS2SYSV_STUB_PREFIX): New macro for isa prefix.
> (MS2SYSV_STUB_BEGIN, MS2SYSV_STUB_END): New macros for stub headers.
> config/i386/resms64.S: Rename to a header file, use MS2SYSV_STUB_BEGIN
> instead of HIDDEN_FUNC and MS2SYSV_STUB_END instead of FUNC_END.
> config/i386/resms64f.S: Likewise.
> config/i386/resms64fx.S: Likewise.
> config/i386/resms64x.S: Likewise.
> config/i386/savms64.S: Likewise.
> config/i386/savms64f.S: Likewise.
> config/i386/avx_resms64.S: New file that only defines a macro and
> includes it's corresponding header file.
> config/i386/avx_resms64f.S: Likewise.
> config/i386/avx_resms64fx.S: Likewise.
> config/i386/avx_resms64x.S: Likewise.
> config/i386/avx_savms64.S: Likewise.
> config/i386/avx_savms64f.S: Likewise.
> config/i386/sse_resms64.S: Likewise.
> config/i386/sse_resms64f.S: Likewise.
> config/i386/sse_resms64fx.S: Likewise.
> config/i386/sse_resms64x.S: Likewise.
> config/i386/sse_savms64.S: Likewise.
> config/i386/sse_savms64f.S: Likewise.
> config/i386/t-msabi: Modified to add avx and sse versions of stubs.

OK.

Thanks,
Uros.

> Signed-off-by: Daniel Santos 
> ---
>  gcc/config/i386/i386.c  | 15 ++-
>  gcc/testsuite/gcc.target/i386/pr82196-1.c   | 14 ++
>  gcc/testsuite/gcc.target/i386/pr82196-2.c   | 14 ++
>  libgcc/config/i386/avx_resms64.S|  2 ++
>  libgcc/config/i386/avx_resms64f.S   |  2 ++
>  libgcc/config/i386/avx_resms64fx.S  |  2 ++
>  libgcc/config/i386/avx_resms64x.S   |  2 ++
>  libgcc/config/i386/avx_savms64.S|  2 ++
>  libgcc/config/i386/avx_savms64f.S   |  2 ++
>  libgcc/config/i386/i386-asm.h   | 34 
> -
>  libgcc/config/i386/{resms64.S => resms64.h} | 28 ++--
>  libgcc/config/i386/{resms64f.S => resms64f.h}   | 24 -
>  libgcc/config/i386/{resms64fx.S => resms64fx.h} | 24 -
>  libgcc/config/i386/{resms64x.S => resms64x.h}   | 28 ++--
>  libgcc/config/i386/{savms64.S => savms64.h} | 28 ++--
>  libgcc/config/i386/{savms64f.S => savms64f.h}   | 24 -
>  libgcc/config/i386/sse_resms64.S|  2 ++
>  libgcc/config/i386/sse_resms64f.S   |  2 ++
>  libgcc/config/i386/sse_resms64fx.S  |  2 ++
>  libgcc/config/i386/sse_resms64x.S   |  2 ++
>  libgcc/config/i386/sse_savms64.S|  2 ++
>  libgcc/config/i386/sse_savms64f.S   |  2 ++
>  libgcc/config/i386/t-msabi  | 18 -
>  23 files changed, 173 insertions(+), 102 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr82196-1.c
>  create mode 100644 gcc/testsuite/gcc.target/i386/pr82196-2.c
>  create mode 100644 libgcc/config/i386/avx_resms64.S
>  create mode 100644 libgcc/config/i386/avx_resms64f.S
>  create mode 100644 libgcc/config/i386/avx_resms64fx.S
>  create mode 100644 libgcc/config/i386/avx_resms64x.S
>  create mode 100644 libgcc/config/i386/avx_savms64.S
>  create mode 100644 libgcc/config/i386/avx_savms64f.S
>  rename libgcc/config/i386/{resms64.S => resms64.h} (76%)
>  rename libgcc/config/i386/{resms64f.S => resms64f.h} (79%)
>  rename libgcc/config/i386/{resms64fx.S => resms64fx.h} (79%)
>  rename libgcc/config/i386/{resms64x.S => resms64x.h} (77%)
>  rename libgcc/config/i386/{savms64.S => savms64.h} (76%)
>  rename libgcc/config/i386/{savms64f.S => savms64f.h} (79%)
>  create mode 100644 libgcc/config/i386/sse_resms64.S
>  create mode 100644 libgcc/config/i386/sse_resms64f.S
>  create mode 100644 libgcc/config/i386/sse_resms64fx.S
>  create mode 100644 libgcc/config/i386/sse_resms64x.S
>  create mode 100644 

[PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV

2017-09-13 Thread Daniel Santos
I made a silly mistake in libgcc by testing the cpp macro __AVX__ to
determine rather to use movaps or vmovaps in the stubs.  This resulted
in the stubs choice of instruction being decided by the machine flags
when the compiler was built rather than those being supplied at the
command line.  This patch splits stubs into separate sse and avx
versions so that both are available.

gcc:
config/i386/i386.c: (xlogue_layout::STUB_NAME_MAX_LEN): Increase to 20
bytes.
(xlogue_layout::s_stub_names): Add an additional size-2 diminsion.
(xlogue_layout::get_stub_name): Modify to select the appropairate sse
and avx version of the stub.

gcc/testsuite:
gcc.target/i386/pr82196-1.c: New test.
gcc.target/i386/pr82196-2.c: Likewise.

libgcc:
config/i386/i386-asm.h (PASTE2): New macro.
(ASMNAME): Modify to use PASTE2.
(MS2SYSV_STUB_PREFIX): New macro for isa prefix.
(MS2SYSV_STUB_BEGIN, MS2SYSV_STUB_END): New macros for stub headers.
config/i386/resms64.S: Rename to a header file, use MS2SYSV_STUB_BEGIN
instead of HIDDEN_FUNC and MS2SYSV_STUB_END instead of FUNC_END.
config/i386/resms64f.S: Likewise.
config/i386/resms64fx.S: Likewise.
config/i386/resms64x.S: Likewise.
config/i386/savms64.S: Likewise.
config/i386/savms64f.S: Likewise.
config/i386/avx_resms64.S: New file that only defines a macro and
includes it's corresponding header file.
config/i386/avx_resms64f.S: Likewise.
config/i386/avx_resms64fx.S: Likewise.
config/i386/avx_resms64x.S: Likewise.
config/i386/avx_savms64.S: Likewise.
config/i386/avx_savms64f.S: Likewise.
config/i386/sse_resms64.S: Likewise.
config/i386/sse_resms64f.S: Likewise.
config/i386/sse_resms64fx.S: Likewise.
config/i386/sse_resms64x.S: Likewise.
config/i386/sse_savms64.S: Likewise.
config/i386/sse_savms64f.S: Likewise.
config/i386/t-msabi: Modified to add avx and sse versions of stubs.
Signed-off-by: Daniel Santos 
---
 gcc/config/i386/i386.c  | 15 ++-
 gcc/testsuite/gcc.target/i386/pr82196-1.c   | 14 ++
 gcc/testsuite/gcc.target/i386/pr82196-2.c   | 14 ++
 libgcc/config/i386/avx_resms64.S|  2 ++
 libgcc/config/i386/avx_resms64f.S   |  2 ++
 libgcc/config/i386/avx_resms64fx.S  |  2 ++
 libgcc/config/i386/avx_resms64x.S   |  2 ++
 libgcc/config/i386/avx_savms64.S|  2 ++
 libgcc/config/i386/avx_savms64f.S   |  2 ++
 libgcc/config/i386/i386-asm.h   | 34 -
 libgcc/config/i386/{resms64.S => resms64.h} | 28 ++--
 libgcc/config/i386/{resms64f.S => resms64f.h}   | 24 -
 libgcc/config/i386/{resms64fx.S => resms64fx.h} | 24 -
 libgcc/config/i386/{resms64x.S => resms64x.h}   | 28 ++--
 libgcc/config/i386/{savms64.S => savms64.h} | 28 ++--
 libgcc/config/i386/{savms64f.S => savms64f.h}   | 24 -
 libgcc/config/i386/sse_resms64.S|  2 ++
 libgcc/config/i386/sse_resms64f.S   |  2 ++
 libgcc/config/i386/sse_resms64fx.S  |  2 ++
 libgcc/config/i386/sse_resms64x.S   |  2 ++
 libgcc/config/i386/sse_savms64.S|  2 ++
 libgcc/config/i386/sse_savms64f.S   |  2 ++
 libgcc/config/i386/t-msabi  | 18 -
 23 files changed, 173 insertions(+), 102 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr82196-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr82196-2.c
 create mode 100644 libgcc/config/i386/avx_resms64.S
 create mode 100644 libgcc/config/i386/avx_resms64f.S
 create mode 100644 libgcc/config/i386/avx_resms64fx.S
 create mode 100644 libgcc/config/i386/avx_resms64x.S
 create mode 100644 libgcc/config/i386/avx_savms64.S
 create mode 100644 libgcc/config/i386/avx_savms64f.S
 rename libgcc/config/i386/{resms64.S => resms64.h} (76%)
 rename libgcc/config/i386/{resms64f.S => resms64f.h} (79%)
 rename libgcc/config/i386/{resms64fx.S => resms64fx.h} (79%)
 rename libgcc/config/i386/{resms64x.S => resms64x.h} (77%)
 rename libgcc/config/i386/{savms64.S => savms64.h} (76%)
 rename libgcc/config/i386/{savms64f.S => savms64f.h} (79%)
 create mode 100644 libgcc/config/i386/sse_resms64.S
 create mode 100644 libgcc/config/i386/sse_resms64f.S
 create mode 100644 libgcc/config/i386/sse_resms64fx.S
 create mode 100644 libgcc/config/i386/sse_resms64x.S
 create mode 100644 libgcc/config/i386/sse_savms64.S
 create mode 100644 libgcc/config/i386/sse_savms64f.S

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index b2b02acc58a..f0d7d0eb196 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -2513,7 +2513,7 @@ public:
   static const