diff mbox

Fix "no-vsx" target attribute handling (PR target/69969)

Message ID 20160226192737.GL3017@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Feb. 26, 2016, 7:27 p.m. UTC
Hi!

Most of the errors and warnings in rs6000_option_override_internal
are emitted only if the particular option is explicit, e.g.
  if (TARGET_P9_DFORM && !TARGET_P9_VECTOR)
    {
      if (rs6000_isa_flags_explicit & OPTION_MASK_P9_VECTOR)
        error ("-mpower9-dform requires -mpower9-vector");
      rs6000_isa_flags &= ~OPTION_MASK_P9_DFORM;
    }
and many others, which is right, but for the
-mallow-movmisalign requires -mvsx
error it doesn't do this, so if say -mcpu=power8 compiled TU
contains a routine with target ("no-vsx") attribute, we get this
error, even when the user hasn't done anything we should complain about.

Fixed by following what we do for the other options, bootstrapped/regtested
on powerpc64le-linux (and powerpc64-linux, but regtest is still pending
there).  Ok for trunk?

2016-02-26  Jakub Jelinek  <jakub@redhat.com>

	PR target/69969
	* config/rs6000/rs6000.c (rs6000_option_override_internal): Don't
	complain about -mallow-movmisalign without -mvsx if
	TARGET_ALLOW_MOVMISALIGN was not set explicitly.

	* gcc.target/powerpc/pr69969.c: New test.


	Jakub

Comments

David Edelsohn Feb. 26, 2016, 8:07 p.m. UTC | #1
On Fri, Feb 26, 2016 at 2:27 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> Hi!
>
> Most of the errors and warnings in rs6000_option_override_internal
> are emitted only if the particular option is explicit, e.g.
>   if (TARGET_P9_DFORM && !TARGET_P9_VECTOR)
>     {
>       if (rs6000_isa_flags_explicit & OPTION_MASK_P9_VECTOR)
>         error ("-mpower9-dform requires -mpower9-vector");
>       rs6000_isa_flags &= ~OPTION_MASK_P9_DFORM;
>     }
> and many others, which is right, but for the
> -mallow-movmisalign requires -mvsx
> error it doesn't do this, so if say -mcpu=power8 compiled TU
> contains a routine with target ("no-vsx") attribute, we get this
> error, even when the user hasn't done anything we should complain about.
>
> Fixed by following what we do for the other options, bootstrapped/regtested
> on powerpc64le-linux (and powerpc64-linux, but regtest is still pending
> there).  Ok for trunk?
>
> 2016-02-26  Jakub Jelinek  <jakub@redhat.com>
>
>         PR target/69969
>         * config/rs6000/rs6000.c (rs6000_option_override_internal): Don't
>         complain about -mallow-movmisalign without -mvsx if
>         TARGET_ALLOW_MOVMISALIGN was not set explicitly.
>
>         * gcc.target/powerpc/pr69969.c: New test.

Seems reasonable.  LGTM

Thanks, David
diff mbox

Patch

--- gcc/config/rs6000/rs6000.c.jj	2016-02-26 12:05:39.000000000 +0100
+++ gcc/config/rs6000/rs6000.c	2016-02-26 15:58:29.250259330 +0100
@@ -4207,7 +4207,8 @@  rs6000_option_override_internal (bool gl
 
   else if (TARGET_ALLOW_MOVMISALIGN && !TARGET_VSX)
     {
-      if (TARGET_ALLOW_MOVMISALIGN > 0)
+      if (TARGET_ALLOW_MOVMISALIGN > 0
+	  && global_options_set.x_TARGET_ALLOW_MOVMISALIGN)
 	error ("-mallow-movmisalign requires -mvsx");
 
       TARGET_ALLOW_MOVMISALIGN = 0;
--- gcc/testsuite/gcc.target/powerpc/pr69969.c.jj	2016-02-26 16:03:34.992101828 +0100
+++ gcc/testsuite/gcc.target/powerpc/pr69969.c	2016-02-26 16:03:25.000000000 +0100
@@ -0,0 +1,7 @@ 
+/* PR target/69969 */
+/* { dg-do compile } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
+/* { dg-options "-mcpu=power8" } */
+
+int bar (int x) { return x; }
+__attribute__((__target__("no-vsx"))) int foo (int x) { return x; } /* { dg-bogus "-mallow-movmisalign requires -mvsx" } */