From: H.J. Lu Date: Tue, 8 Jan 2019 17:40:18 +0000 (+0000) Subject: x86: Don't generate vzeroupper if caller passes AVX/AVX512 registers X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=53ef4e3a942fc5848690dbf36e67c8c68f7fbae4;p=gcc.git x86: Don't generate vzeroupper if caller passes AVX/AVX512 registers There is no need to generate vzeroupper if caller passes arguments in AVX/AVX512 registers. Tested on i686 and x86-64 with and without --with-arch=native. gcc/ PR target/88717 * config/i386/i386.c (ix86_avx_u128_mode_exit): Call ix86_avx_u128_mode_entry. gcc/testsuite/ PR target/88717 * gcc.target/i386/pr88717.c: New test. From-SVN: r267732 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c512ff496a8..7b4f6e5270b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-01-08 H.J. Lu + + PR target/88717 + * config/i386/i386.c (ix86_avx_u128_mode_exit): Call + ix86_avx_u128_mode_entry. + 2019-01-08 Martin Liska PR tree-optimization/88753 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index d01278d866f..bd48e080f46 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -19137,7 +19137,10 @@ ix86_avx_u128_mode_exit (void) if (reg && ix86_check_avx_upper_register (reg)) return AVX_U128_DIRTY; - return AVX_U128_CLEAN; + /* Exit mode is set to AVX_U128_DIRTY if there are 256bit or 512bit + modes used in function arguments, otherwise return AVX_U128_CLEAN. + */ + return ix86_avx_u128_mode_entry (); } /* Return a mode that ENTITY is assumed to be diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4a70997cbed..28439297735 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-01-08 H.J. Lu + + PR target/88717 + * gcc.target/i386/pr88717.c: New test. + 2019-01-08 Marek Polacek PR c++/88548 - this accepted in static member functions. diff --git a/gcc/testsuite/gcc.target/i386/pr88717.c b/gcc/testsuite/gcc.target/i386/pr88717.c new file mode 100644 index 00000000000..01680998f1b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr88717.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -mavx512f -mvzeroupper" } */ + +#include + +__m128 +foo1 (__m256 x) +{ + return _mm256_castps256_ps128 (x); +} + +void +foo2 (float *p, __m256 x) +{ + *p = ((__v8sf)x)[0]; +} + +void +foo3 (float *p, __m512 x) +{ + *p = ((__v16sf)x)[0]; +} + +/* { dg-final { scan-assembler-not "vzeroupper" } } */