diff options
author | Haochen Jiang <haochen.jiang@intel.com> | 2023-08-17 14:13:28 +0800 |
---|---|---|
committer | Haochen Jiang <haochen.jiang@intel.com> | 2023-08-17 14:14:35 +0800 |
commit | 0288ab14732a16b3787546cdd159941eb7306cf3 (patch) | |
tree | 1e5e3ad58283738f11be19b5a7dcb7526091c0ca | |
parent | 11ad44da01dd1c91c96e45802fd8b1c50e88703f (diff) | |
download | gcc-0288ab14732a16b3787546cdd159941eb7306cf3.zip gcc-0288ab14732a16b3787546cdd159941eb7306cf3.tar.gz gcc-0288ab14732a16b3787546cdd159941eb7306cf3.tar.bz2 |
Emit a warning when disabling AVX512 with AVX10 enabled or disabling AVX10 with AVX512 enabled
gcc/ChangeLog:
* common/config/i386/i386-common.cc
(ix86_check_avx10): New function to check isa_flags and
isa_flags_explicit to emit warning when AVX10 is enabled
by "-m" option.
(ix86_check_avx512): New function to check isa_flags and
isa_flags_explicit to emit warning when AVX512 is enabled
by "-m" option.
(ix86_handle_option): Do not change the flags when warning
is emitted.
* config/i386/driver-i386.cc (host_detect_local_cpu):
Do not append -mno-avx10.1 for -march=native.
gcc/testsuite/ChangeLog:
* gcc.target/i386/avx10_1-11.c: New test.
* gcc.target/i386/avx10_1-12.c: Ditto.
* gcc.target/i386/avx10_1-13.c: Ditto.
* gcc.target/i386/avx10_1-14.c: Ditto.
-rw-r--r-- | gcc/common/config/i386/i386-common.cc | 68 | ||||
-rw-r--r-- | gcc/config/i386/driver-i386.cc | 2 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/avx10_1-11.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/avx10_1-12.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/avx10_1-13.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/i386/avx10_1-14.c | 13 |
6 files changed, 91 insertions, 15 deletions
diff --git a/gcc/common/config/i386/i386-common.cc b/gcc/common/config/i386/i386-common.cc index 6c3bebb..ec94251 100644 --- a/gcc/common/config/i386/i386-common.cc +++ b/gcc/common/config/i386/i386-common.cc @@ -388,6 +388,46 @@ set_malign_value (const char **flag, unsigned value) *flag = r; } +/* Emit a warning when using -mno-avx512{f,vl,bw,dq,cd,bf16,fp16,vbmi,vbmi2, + vnni,ifma,bitalg,vpopcntdq} with -mavx10.1 and above. */ +static bool +ix86_check_avx10 (struct gcc_options *opts) +{ + if (opts->x_ix86_isa_flags2 & opts->x_ix86_isa_flags2_explicit + & OPTION_MASK_ISA2_AVX10_1) + { + warning (0, "%<-mno-avx512{f,vl,bw,dq,cd,bf16,fp16,vbmi,vbmi2,vnni,ifma," + "bitalg,vpopcntdq}%> are ignored with %<-mavx10.1%> and above"); + return false; + } + + return true; +} + +/* Emit a warning when using -mno-avx10.1 with -mavx512{f,vl,bw,dq,cd,bf16, + fp16,vbmi,vbmi2,vnni,ifma,bitalg,vpopcntdq}. */ +static bool +ix86_check_avx512 (struct gcc_options *opts) +{ + if ((opts->x_ix86_isa_flags & opts->x_ix86_isa_flags_explicit + & (OPTION_MASK_ISA_AVX512F | OPTION_MASK_ISA_AVX512CD + | OPTION_MASK_ISA_AVX512DQ | OPTION_MASK_ISA_AVX512BW + | OPTION_MASK_ISA_AVX512VL | OPTION_MASK_ISA_AVX512IFMA + | OPTION_MASK_ISA_AVX512VBMI | OPTION_MASK_ISA_AVX512VBMI2 + | OPTION_MASK_ISA_AVX512VNNI | OPTION_MASK_ISA_AVX512VPOPCNTDQ + | OPTION_MASK_ISA_AVX512BITALG)) + || (opts->x_ix86_isa_flags2 & opts->x_ix86_isa_flags2_explicit + & (OPTION_MASK_ISA2_AVX512FP16 | OPTION_MASK_ISA2_AVX512BF16))) + { + warning (0, "%<-mno-avx10.1%> is ignored when using with " + "%<-mavx512{f,vl,bw,dq,cd,bf16,fp16,vbmi,vbmi2,vnni," + "ifma,bitalg,vpopcntdq}%>"); + return false; + } + + return true; +} + /* Implement TARGET_HANDLE_OPTION. */ bool @@ -609,7 +649,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512F_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512F_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX512F_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512F_UNSET; @@ -624,7 +664,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512CD_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512CD_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX512CD_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512CD_UNSET; @@ -898,7 +938,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512VBMI2_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512VBMI2_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX512VBMI2_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512VBMI2_UNSET; @@ -913,7 +953,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512FP16_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512FP16_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX512FP16_UNSET; opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX512FP16_UNSET; @@ -926,7 +966,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512VNNI_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512VNNI_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX512VNNI_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512VNNI_UNSET; @@ -940,7 +980,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512VPOPCNTDQ_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX512VPOPCNTDQ_UNSET; opts->x_ix86_isa_flags_explicit @@ -954,7 +994,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512BITALG_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512BITALG_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX512BITALG_UNSET; opts->x_ix86_isa_flags_explicit @@ -970,7 +1010,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512BW_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512BW_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX512BF16_UNSET; opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX512BF16_UNSET; @@ -1037,7 +1077,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512DQ_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512DQ_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX512DQ_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512DQ_UNSET; @@ -1050,7 +1090,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512BW_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512BW_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX512BW_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512BW_UNSET; @@ -1065,7 +1105,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512VL_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512VL_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX512VL_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512VL_UNSET; @@ -1078,7 +1118,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512IFMA_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512IFMA_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX512IFMA_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512IFMA_UNSET; @@ -1091,7 +1131,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX512VBMI_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512VBMI_SET; } - else + else if (ix86_check_avx10 (opts)) { opts->x_ix86_isa_flags &= ~OPTION_MASK_ISA_AVX512VBMI_UNSET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX512VBMI_UNSET; @@ -1367,7 +1407,7 @@ ix86_handle_option (struct gcc_options *opts, opts->x_ix86_isa_flags |= OPTION_MASK_ISA_AVX2_SET; opts->x_ix86_isa_flags_explicit |= OPTION_MASK_ISA_AVX2_SET; } - else + else if (ix86_check_avx512 (opts)) { opts->x_ix86_isa_flags2 &= ~OPTION_MASK_ISA2_AVX10_1_UNSET; opts->x_ix86_isa_flags2_explicit |= OPTION_MASK_ISA2_AVX10_1_UNSET; diff --git a/gcc/config/i386/driver-i386.cc b/gcc/config/i386/driver-i386.cc index 08d0aed..227ace6 100644 --- a/gcc/config/i386/driver-i386.cc +++ b/gcc/config/i386/driver-i386.cc @@ -854,7 +854,7 @@ const char *host_detect_local_cpu (int argc, const char **argv) options = concat (options, " ", isa_names_table[i].option, NULL); } - else + else if (isa_names_table[i].feature != FEATURE_AVX10_1) options = concat (options, neg_option, isa_names_table[i].option + 2, NULL); } diff --git a/gcc/testsuite/gcc.target/i386/avx10_1-11.c b/gcc/testsuite/gcc.target/i386/avx10_1-11.c new file mode 100644 index 0000000..10c8d78 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx10_1-11.c @@ -0,0 +1,5 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -march=x86-64 -mavx10.1 -mno-avx512f" } */ +/* { dg-warning "'-mno-avx512{f,vl,bw,dq,cd,bf16,fp16,vbmi,vbmi2,vnni,ifma,bitalg,vpopcntdq}' are ignored with '-mavx10.1' and above" "" { target *-*-* } 0 } */ + +#include "avx10_1-1.c" diff --git a/gcc/testsuite/gcc.target/i386/avx10_1-12.c b/gcc/testsuite/gcc.target/i386/avx10_1-12.c new file mode 100644 index 0000000..b79c92a --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx10_1-12.c @@ -0,0 +1,13 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2" } */ + +#include <immintrin.h> + +__attribute__ ((target ("avx10.1,no-avx512f"))) void +f1 () +{ /* { dg-warning "'-mno-avx512{f,vl,bw,dq,cd,bf16,fp16,vbmi,vbmi2,vnni,ifma,bitalg,vpopcntdq}' are ignored with '-mavx10.1' and above" } */ + register __m256d a __asm ("ymm17"); + register __m256d b __asm ("ymm16"); + a = _mm256_add_pd (a, b); + asm volatile ("" : "+v" (a)); +} diff --git a/gcc/testsuite/gcc.target/i386/avx10_1-13.c b/gcc/testsuite/gcc.target/i386/avx10_1-13.c new file mode 100644 index 0000000..156d59f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx10_1-13.c @@ -0,0 +1,5 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-O2 -march=x86-64 -mavx512f -mno-avx10.1" } */ +/* { dg-warning "'-mno-avx10.1' is ignored when using with '-mavx512{f,vl,bw,dq,cd,bf16,fp16,vbmi,vbmi2,vnni,ifma,bitalg,vpopcntdq}'" "" { target *-*-* } 0 } */ + +#include "avx10_1-2.c" diff --git a/gcc/testsuite/gcc.target/i386/avx10_1-14.c b/gcc/testsuite/gcc.target/i386/avx10_1-14.c new file mode 100644 index 0000000..23d2ba8 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/avx10_1-14.c @@ -0,0 +1,13 @@ +/* { dg-do compile } */ +/* { dg-options "-march=x86-64" } */ +/* { dg-final { scan-assembler "%zmm" } } */ + +typedef double __m512d __attribute__ ((__vector_size__ (64), __may_alias__)); + +__attribute__ ((target ("avx512f,no-avx10.1"))) __m512d +foo () +{ /* { dg-warning "'-mno-avx10.1' is ignored when using with '-mavx512{f,vl,bw,dq,cd,bf16,fp16,vbmi,vbmi2,vnni,ifma,bitalg,vpopcntdq}'" } */ + __m512d a, b; + a = a + b; + return a; +} |