i386: Properly set ix86_isa_flags

Message ID 43f8282f-db1a-4f80-1a9d-5522f0d11de7@suse.cz
State New
Headers show
Series
  • i386: Properly set ix86_isa_flags
Related show

Commit Message

Martin Liška March 8, 2021, 12:52 p.m.
Hi.

The bug is about usage of ix86_isa_flags instead of opts->x_ix86_isa_flags.
I'm planning a bigger refactoring regarding the flags & PTA_PCLMUL conditions.

Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

Ready to be installed?
Thanks,
Martin

gcc/ChangeLog:

	PR target/99464
	* config/i386/i386-options.c (ix86_option_override_internal):
	Set isa_flags for OPTS argument and not for the global
	global_options.

gcc/testsuite/ChangeLog:

	PR target/99464
	* gcc.target/i386/pr99464.c: New test.
---
  gcc/config/i386/i386-options.c          |  8 ++++----
  gcc/testsuite/gcc.target/i386/pr99464.c | 15 +++++++++++++++
  2 files changed, 19 insertions(+), 4 deletions(-)
  create mode 100644 gcc/testsuite/gcc.target/i386/pr99464.c

-- 
2.30.1

Comments

Richard Purdie via Gcc-patches March 8, 2021, 7:53 p.m. | #1
On Mon, Mar 8, 2021 at 2:52 PM Martin Liška <mliska@suse.cz> wrote:
>

> Hi.

>

> The bug is about usage of ix86_isa_flags instead of opts->x_ix86_isa_flags.

> I'm planning a bigger refactoring regarding the flags & PTA_PCLMUL conditions.

>

> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.

>

> Ready to be installed?

> Thanks,

> Martin

>

> gcc/ChangeLog:

>

>         PR target/99464

>         * config/i386/i386-options.c (ix86_option_override_internal):

>         Set isa_flags for OPTS argument and not for the global

>         global_options.

>

> gcc/testsuite/ChangeLog:

>

>         PR target/99464

>         * gcc.target/i386/pr99464.c: New test.


OK.

Thanks,
Uros.

> ---

>   gcc/config/i386/i386-options.c          |  8 ++++----

>   gcc/testsuite/gcc.target/i386/pr99464.c | 15 +++++++++++++++

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

>   create mode 100644 gcc/testsuite/gcc.target/i386/pr99464.c

>

> diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c

> index cdeabbfca4b..982c335e1fa 100644

> --- a/gcc/config/i386/i386-options.c

> +++ b/gcc/config/i386/i386-options.c

> @@ -2159,11 +2159,11 @@ ix86_option_override_internal (bool main_args_p,

>             && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA2_MOVBE))

>           opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_MOVBE;

>         if (((processor_alias_table[i].flags & PTA_AES) != 0)

> -           && !(ix86_isa_flags_explicit & OPTION_MASK_ISA_AES))

> -         ix86_isa_flags |= OPTION_MASK_ISA_AES;

> +           && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AES))

> +         opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AES;

>         if (((processor_alias_table[i].flags & PTA_SHA) != 0)

> -           && !(ix86_isa_flags_explicit & OPTION_MASK_ISA_SHA))

> -         ix86_isa_flags |= OPTION_MASK_ISA_SHA;

> +           && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_SHA))

> +         opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SHA;

>         if (((processor_alias_table[i].flags & PTA_PCLMUL) != 0)

>             && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_PCLMUL))

>           opts->x_ix86_isa_flags |= OPTION_MASK_ISA_PCLMUL;

> diff --git a/gcc/testsuite/gcc.target/i386/pr99464.c b/gcc/testsuite/gcc.target/i386/pr99464.c

> new file mode 100644

> index 00000000000..98dd938973e

> --- /dev/null

> +++ b/gcc/testsuite/gcc.target/i386/pr99464.c

> @@ -0,0 +1,15 @@

> +/* PR target/99464 */

> +/* { dg-do compile } */

> +/* { dg-options "-O2" } */

> +

> +#pragma GCC target("arch=cannonlake")

> +

> +#include <immintrin.h>

> +

> +volatile __m128i x;

> +

> +void extern

> +sha_test (void)

> +{

> +  x = _mm_sha1msg1_epu32 (x, x);

> +}

> --

> 2.30.1

>

Patch

diff --git a/gcc/config/i386/i386-options.c b/gcc/config/i386/i386-options.c
index cdeabbfca4b..982c335e1fa 100644
--- a/gcc/config/i386/i386-options.c
+++ b/gcc/config/i386/i386-options.c
@@ -2159,11 +2159,11 @@  ix86_option_override_internal (bool main_args_p,
  	    && !(opts->x_ix86_isa_flags2_explicit & OPTION_MASK_ISA2_MOVBE))
  	  opts->x_ix86_isa_flags2 |= OPTION_MASK_ISA2_MOVBE;
  	if (((processor_alias_table[i].flags & PTA_AES) != 0)
-	    && !(ix86_isa_flags_explicit & OPTION_MASK_ISA_AES))
-	  ix86_isa_flags |= OPTION_MASK_ISA_AES;
+	    && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_AES))
+	  opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AES;
  	if (((processor_alias_table[i].flags & PTA_SHA) != 0)
-	    && !(ix86_isa_flags_explicit & OPTION_MASK_ISA_SHA))
-	  ix86_isa_flags |= OPTION_MASK_ISA_SHA;
+	    && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_SHA))
+	  opts->x_ix86_isa_flags |= OPTION_MASK_ISA_SHA;
  	if (((processor_alias_table[i].flags & PTA_PCLMUL) != 0)
  	    && !(opts->x_ix86_isa_flags_explicit & OPTION_MASK_ISA_PCLMUL))
  	  opts->x_ix86_isa_flags |= OPTION_MASK_ISA_PCLMUL;
diff --git a/gcc/testsuite/gcc.target/i386/pr99464.c b/gcc/testsuite/gcc.target/i386/pr99464.c
new file mode 100644
index 00000000000..98dd938973e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr99464.c
@@ -0,0 +1,15 @@ 
+/* PR target/99464 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#pragma GCC target("arch=cannonlake")
+
+#include <immintrin.h>
+
+volatile __m128i x;
+
+void extern
+sha_test (void)
+{
+  x = _mm_sha1msg1_epu32 (x, x);
+}