This is the mail archive of the gcc-patches@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: [PATCH] [i386, libgcc] PR 82196 -mcall-ms2sysv-xlogues emits wrong AVX/SSE MOV


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.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

Wow, thanks for that Jakub!  I was thinking to just omit the support if
the bootstrapping assembler doesn't support it, presuming that it would
be the same assembler used to actually compile programs later.  This
might be a bad assumption, so this sounds like a better idea since the
offsets are always the same.

Thanks,
Daniel


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