i386: Don't pass -msse2avx to assembler for -mavx

Message ID 20181004230139.GA6438@intel.com
State New
Headers show
Series
  • i386: Don't pass -msse2avx to assembler for -mavx
Related show

Commit Message

H.J. Lu Oct. 4, 2018, 11:01 p.m.
With

gcc -O2 -fPIC -flto -g -c -o a.o a.c
gcc -O2 -fPIC -flto -g -mavx   -c -o b.o b.c
gcc -shared -O2 -fPIC -flto -g -o lib1.so a.o b.o

LTO correctly generates AVX for b.o and SSE for a.o.  But the GCC driver
passes -msse2avx to assembler, which encodes SSE instructions as AVX
instructions.  We shouldn't pass -msse2avx to assembler for -mavx.

Tested on x86-64.  OK for trunk?

Thanks.

H.J.
---
	PR target/87522
	* config/i386/gnu-user.h (ASM_SPEC): Don't pass -msse2avx to
	assembler for -mavx.
	* config/i386/gnu-user64.h (ASM_SPEC): Likewise.
---
 gcc/config/i386/gnu-user.h   | 2 +-
 gcc/config/i386/gnu-user64.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

-- 
2.17.1

Comments

Uros Bizjak Oct. 5, 2018, 7:15 a.m. | #1
On Fri, Oct 5, 2018 at 1:01 AM H.J. Lu <hongjiu.lu@intel.com> wrote:
>

>

> With

>

> gcc -O2 -fPIC -flto -g -c -o a.o a.c

> gcc -O2 -fPIC -flto -g -mavx   -c -o b.o b.c

> gcc -shared -O2 -fPIC -flto -g -o lib1.so a.o b.o

>

> LTO correctly generates AVX for b.o and SSE for a.o.  But the GCC driver

> passes -msse2avx to assembler, which encodes SSE instructions as AVX

> instructions.  We shouldn't pass -msse2avx to assembler for -mavx.

>

> Tested on x86-64.  OK for trunk?

>

> Thanks.

>

> H.J.

> ---

>         PR target/87522

>         * config/i386/gnu-user.h (ASM_SPEC): Don't pass -msse2avx to

>         assembler for -mavx.

>         * config/i386/gnu-user64.h (ASM_SPEC): Likewise.


OK for mainline and backports.

Thanks,
Uros.

>  gcc/config/i386/gnu-user.h   | 2 +-

>  gcc/config/i386/gnu-user64.h | 2 +-

>  2 files changed, 2 insertions(+), 2 deletions(-)

>

> diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h

> index a922c9b93fa..baed87aa54f 100644

> --- a/gcc/config/i386/gnu-user.h

> +++ b/gcc/config/i386/gnu-user.h

> @@ -67,7 +67,7 @@ along with GCC; see the file COPYING3.  If not see

>

>  #undef  ASM_SPEC

>  #define ASM_SPEC \

> -  "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"

> +  "--32 %{msse2avx:%{!mavx:-msse2avx}}"

>

>  #undef  SUBTARGET_EXTRA_SPECS

>  #define SUBTARGET_EXTRA_SPECS \

> diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h

> index f7a68fdecf0..09141ce3508 100644

> --- a/gcc/config/i386/gnu-user64.h

> +++ b/gcc/config/i386/gnu-user64.h

> @@ -50,7 +50,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see

>  #define ASM_SPEC "%{" SPEC_32 ":--32} \

>   %{" SPEC_64 ":--64} \

>   %{" SPEC_X32 ":--x32} \

> - %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"

> + %{msse2avx:%{!mavx:-msse2avx}}"

>

>  #define GNU_USER_TARGET_LINK_SPEC                                 \

>                    "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \

> --

> 2.17.1

>
Gunther Nikl Oct. 7, 2018, 9:18 a.m. | #2
Uros Bizjak <ubizjak@gmail.com> wrote:
> On Fri, Oct 5, 2018@1:01 AM H.J. Lu <hongjiu.lu@intel.com> wrote:

> > diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h

> > index a922c9b93fa..baed87aa54f 100644

> > --- a/gcc/config/i386/gnu-user.h

> > +++ b/gcc/config/i386/gnu-user.h

> > @@ -67,7 +67,7 @@ along with GCC; see the file COPYING3.  If not see

> >

> >  #undef  ASM_SPEC

> >  #define ASM_SPEC \

> > -  "--32 %{!mno-sse2avx:%{mavx:-msse2avx}}

> > %{msse2avx:%{!mavx:-msse2avx}}"

> > +  "--32 %{msse2avx:%{!mavx:-msse2avx}}"


AFAICT, this could be written as "%{!mavx:{msse2avx}}".

Regards,
Gunther Nikl

> >  #undef  SUBTARGET_EXTRA_SPECS

> >  #define SUBTARGET_EXTRA_SPECS \

> > diff --git a/gcc/config/i386/gnu-user64.h

> > b/gcc/config/i386/gnu-user64.h index f7a68fdecf0..09141ce3508 100644

> > --- a/gcc/config/i386/gnu-user64.h

> > +++ b/gcc/config/i386/gnu-user64.h

> > @@ -50,7 +50,7 @@ see the files COPYING3 and COPYING.RUNTIME

> > respectively.  If not, see #define ASM_SPEC "%{" SPEC_32 ":--32} \

> >   %{" SPEC_64 ":--64} \

> >   %{" SPEC_X32 ":--x32} \

> > - %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"

> > + %{msse2avx:%{!mavx:-msse2avx}}"

> >

> >  #define GNU_USER_TARGET_LINK_SPEC                                 \

> >                    "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "}

> > \ --

> > 2.17.1

Patch

diff --git a/gcc/config/i386/gnu-user.h b/gcc/config/i386/gnu-user.h
index a922c9b93fa..baed87aa54f 100644
--- a/gcc/config/i386/gnu-user.h
+++ b/gcc/config/i386/gnu-user.h
@@ -67,7 +67,7 @@  along with GCC; see the file COPYING3.  If not see
 
 #undef  ASM_SPEC
 #define ASM_SPEC \
-  "--32 %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
+  "--32 %{msse2avx:%{!mavx:-msse2avx}}"
 
 #undef  SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS \
diff --git a/gcc/config/i386/gnu-user64.h b/gcc/config/i386/gnu-user64.h
index f7a68fdecf0..09141ce3508 100644
--- a/gcc/config/i386/gnu-user64.h
+++ b/gcc/config/i386/gnu-user64.h
@@ -50,7 +50,7 @@  see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define ASM_SPEC "%{" SPEC_32 ":--32} \
  %{" SPEC_64 ":--64} \
  %{" SPEC_X32 ":--x32} \
- %{!mno-sse2avx:%{mavx:-msse2avx}} %{msse2avx:%{!mavx:-msse2avx}}"
+ %{msse2avx:%{!mavx:-msse2avx}}"
 
 #define GNU_USER_TARGET_LINK_SPEC				   \
                   "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \