[gcc r15-1469] i386: Fix some ISA bit test in option_override

Hongyu Wang hongyuw@gcc.gnu.org
Thu Jun 20 07:15:42 GMT 2024


https://gcc.gnu.org/g:4867cc815531ede8bc356a2507f1c35ee6e6399c

commit r15-1469-g4867cc815531ede8bc356a2507f1c35ee6e6399c
Author: Hongyu Wang <hongyu.wang@intel.com>
Date:   Mon Jun 17 10:34:01 2024 +0800

    i386: Fix some ISA bit test in option_override
    
    Adjust several new feature check in ix86_option_override_interal that
    directly use TARGET_* instead of TARGET_*_P (opts->ix86_isa_flags)
    to avoid cmdline option overrides target_attribute isa flag.
    
    gcc/ChangeLog:
    
            * config/i386/i386-options.cc (ix86_option_override_internal):
            Use TARGET_*_P (opts->x_ix86_isa_flags*) instead of TARGET_*
            for UINTR, LAM and APX_F.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/i386/apx-ccmp-2.c: Remove -mno-apxf in option.
            * gcc.target/i386/funcspec-56.inc: Drop uintr tests.
            * gcc.target/i386/funcspec-6.c: Add uintr tests.

Diff:
---
 gcc/config/i386/i386-options.cc               | 14 +++++++++-----
 gcc/testsuite/gcc.target/i386/apx-ccmp-2.c    |  2 +-
 gcc/testsuite/gcc.target/i386/funcspec-56.inc |  2 --
 gcc/testsuite/gcc.target/i386/funcspec-6.c    |  2 ++
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
index 65c5bad9c285..1ef2c71a7a23 100644
--- a/gcc/config/i386/i386-options.cc
+++ b/gcc/config/i386/i386-options.cc
@@ -2115,15 +2115,18 @@ ix86_option_override_internal (bool main_args_p,
       opts->x_ix86_stringop_alg = no_stringop;
     }
 
-  if (TARGET_APX_F && !TARGET_64BIT)
+  if (TARGET_APX_F_P (opts->x_ix86_isa_flags2)
+      && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
     error ("%<-mapxf%> is not supported for 32-bit code");
-  else if (opts->x_ix86_apx_features != apx_none && !TARGET_64BIT)
+  else if (opts->x_ix86_apx_features != apx_none
+	   && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
     error ("%<-mapx-features=%> option is not supported for 32-bit code");
 
-  if (TARGET_UINTR && !TARGET_64BIT)
+  if (TARGET_UINTR_P (opts->x_ix86_isa_flags2)
+      && !TARGET_64BIT_P (opts->x_ix86_isa_flags))
     error ("%<-muintr%> not supported for 32-bit code");
 
-  if (ix86_lam_type && !TARGET_LP64)
+  if (ix86_lam_type && !TARGET_LP64_P (opts->x_ix86_isa_flags))
     error ("%<-mlam=%> option: [u48|u57] not supported for 32-bit code");
 
   if (!opts->x_ix86_arch_string)
@@ -2504,7 +2507,8 @@ ix86_option_override_internal (bool main_args_p,
   init_machine_status = ix86_init_machine_status;
 
   /* Override APX flag here if ISA bit is set.  */
-  if (TARGET_APX_F && !OPTION_SET_P (ix86_apx_features))
+  if (TARGET_APX_F_P (opts->x_ix86_isa_flags2)
+      && !OPTION_SET_P (ix86_apx_features))
     opts->x_ix86_apx_features = apx_all;
 
   /* Validate -mregparm= value.  */
diff --git a/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c b/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c
index 4a0784394c32..192c04587284 100644
--- a/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c
+++ b/gcc/testsuite/gcc.target/i386/apx-ccmp-2.c
@@ -1,6 +1,6 @@
 /* { dg-do run { target { ! ia32 } } } */
 /* { dg-require-effective-target apxf } */
-/* { dg-options "-O3 -mno-apxf" } */
+/* { dg-options "-O3" } */
 
 __attribute__((noinline, noclone, target("apxf")))
 int foo_apx(int a, int b, int c, int d)
diff --git a/gcc/testsuite/gcc.target/i386/funcspec-56.inc b/gcc/testsuite/gcc.target/i386/funcspec-56.inc
index c4dc89367ef5..e4713eaa88d4 100644
--- a/gcc/testsuite/gcc.target/i386/funcspec-56.inc
+++ b/gcc/testsuite/gcc.target/i386/funcspec-56.inc
@@ -69,7 +69,6 @@ extern void test_avx512vp2intersect (void)	__attribute__((__target__("avx512vp2i
 extern void test_amx_tile (void)		__attribute__((__target__("amx-tile")));
 extern void test_amx_int8 (void)		__attribute__((__target__("amx-int8")));
 extern void test_amx_bf16 (void)		__attribute__((__target__("amx-bf16")));
-extern void test_uintr (void)			__attribute__((__target__("uintr")));
 extern void test_hreset (void)			__attribute__((__target__("hreset")));
 extern void test_keylocker (void)		__attribute__((__target__("kl")));
 extern void test_widekl (void)			__attribute__((__target__("widekl")));
@@ -158,7 +157,6 @@ extern void test_no_avx512vp2intersect (void)	__attribute__((__target__("no-avx5
 extern void test_no_amx_tile (void)		__attribute__((__target__("no-amx-tile")));
 extern void test_no_amx_int8 (void)		__attribute__((__target__("no-amx-int8")));
 extern void test_no_amx_bf16 (void)		__attribute__((__target__("no-amx-bf16")));
-extern void test_no_uintr (void)		__attribute__((__target__("no-uintr")));
 extern void test_no_hreset (void)		__attribute__((__target__("no-hreset")));
 extern void test_no_keylocker (void)		__attribute__((__target__("no-kl")));
 extern void test_no_widekl (void)		__attribute__((__target__("no-widekl")));
diff --git a/gcc/testsuite/gcc.target/i386/funcspec-6.c b/gcc/testsuite/gcc.target/i386/funcspec-6.c
index ea896b7ebfdb..033c9a50e23c 100644
--- a/gcc/testsuite/gcc.target/i386/funcspec-6.c
+++ b/gcc/testsuite/gcc.target/i386/funcspec-6.c
@@ -4,6 +4,8 @@
 
 #include "funcspec-56.inc"
 
+extern void test_uintr (void)			__attribute__((__target__("uintr")));
+extern void test_no_uintr (void)		__attribute__((__target__("no-uintr")));
 extern void test_arch_foo (void)		__attribute__((__target__("arch=foo"))); /* { dg-error "bad value" } */
 
 extern void test_tune_foo (void)		__attribute__((__target__("tune=foo"))); /* { dg-error "bad value" } */


More information about the Gcc-cvs mailing list