Skip to content

Commit c7572ae

Browse files
authored
[X86][AVX10] Re-target mavx10.1 and emit warning for mavx10.x-256/512 and m[no-]evex512 (#132542)
The 256-bit maximum vector register size control was removed from AVX10 whitepaper, ref: https://cdrdv2.intel.com/v1/dl/getContent/784343 - Re-target m[no-]avx10.1 to enable AVX10.1 with 512-bit maximum vector register size; - Emit warning for mavx10.x-256, noting AVX10/256 is not supported; - Emit warning for mavx10.x-512, noting to use m[no-]avx10.x instead; - Emit warning for m[no-]evex512, noting AVX10/256 is not supported; This patch only changes Clang driver behavior. The features avx10.x-256/512 keep unchanged and will be removed in the next release.
1 parent 8d69e95 commit c7572ae

File tree

4 files changed

+44
-26
lines changed

4 files changed

+44
-26
lines changed

clang/docs/ReleaseNotes.rst

+7-4
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,13 @@ Hexagon Support
413413
X86 Support
414414
^^^^^^^^^^^
415415

416-
- Disable ``-m[no-]avx10.1`` and switch ``-m[no-]avx10.2`` to alias of 512 bit
417-
options.
418-
- Change ``-mno-avx10.1-512`` to alias of ``-mno-avx10.1-256`` to disable both
419-
256 and 512 bit instructions.
416+
- The 256-bit maximum vector register size control was removed from
417+
`AVX10 whitepaper <https://cdrdv2.intel.com/v1/dl/getContent/784343>_`.
418+
* Re-target ``m[no-]avx10.1`` to enable AVX10.1 with 512-bit maximum vector register size.
419+
* Emit warning for ``mavx10.x-256``, noting AVX10/256 is not supported.
420+
* Emit warning for ``mavx10.x-512``, noting to use ``m[no-]avx10.x`` instead.
421+
* Emit warning for ``m[no-]evex512``, noting AVX10/256 is not supported.
422+
* The features avx10.x-256/512 keep unchanged and will be removed in the next release.
420423

421424
Arm and AArch64 Support
422425
^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Driver/Options.td

+3-3
Original file line numberDiff line numberDiff line change
@@ -6409,11 +6409,11 @@ def mavx10_1_256 : Flag<["-"], "mavx10.1-256">, Group<m_x86_AVX10_Features_Group
64096409
def mno_avx10_1_256 : Flag<["-"], "mno-avx10.1-256">, Group<m_x86_AVX10_Features_Group>;
64106410
def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, Group<m_x86_AVX10_Features_Group>;
64116411
def mno_avx10_1_512 : Flag<["-"], "mno-avx10.1-512">, Alias<mno_avx10_1_256>;
6412-
def mavx10_1 : Flag<["-"], "mavx10.1">, Flags<[Unsupported]>;
6413-
def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Flags<[Unsupported]>;
6412+
def mavx10_1 : Flag<["-"], "mavx10.1">, Group<m_x86_AVX10_Features_Group>;
6413+
def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Group<m_x86_AVX10_Features_Group>;
64146414
def mavx10_2_256 : Flag<["-"], "mavx10.2-256">, Group<m_x86_AVX10_Features_Group>;
64156415
def mavx10_2_512 : Flag<["-"], "mavx10.2-512">, Group<m_x86_AVX10_Features_Group>;
6416-
def mavx10_2 : Flag<["-"], "mavx10.2">, Alias<mavx10_2_512>;
6416+
def mavx10_2 : Flag<["-"], "mavx10.2">, Group<m_x86_AVX10_Features_Group>;
64176417
def mno_avx10_2 : Flag<["-"], "mno-avx10.2">, Group<m_x86_AVX10_Features_Group>;
64186418
def mavx2 : Flag<["-"], "mavx2">, Group<m_x86_Features_Group>;
64196419
def mno_avx2 : Flag<["-"], "mno-avx2">, Group<m_x86_Features_Group>;

clang/lib/Driver/ToolChains/Arch/X86.cpp

+16-3
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,18 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
243243
assert((Version == "1" || Version == "2") && "Invalid AVX10 feature name.");
244244

245245
if (Width == "") {
246-
assert(IsNegative && "Only negative options can omit width.");
247-
Features.push_back(Args.MakeArgString("-" + Name + "-256"));
246+
if (IsNegative)
247+
Features.push_back(Args.MakeArgString("-" + Name + "-256"));
248+
else
249+
Features.push_back(Args.MakeArgString("+" + Name + "-512"));
248250
} else {
249-
assert((Width == "256" || Width == "512") && "Invalid vector length.");
251+
if (Width == "512")
252+
D.Diag(diag::warn_drv_deprecated_arg) << Name << 1 << Name.drop_back(4);
253+
else if (Width == "256")
254+
D.Diag(diag::warn_drv_deprecated_custom)
255+
<< Name << "because AVX10/256 is not supported and will be removed";
256+
else
257+
assert((Width == "256" || Width == "512") && "Invalid vector length.");
250258
Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
251259
}
252260
}
@@ -275,6 +283,11 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
275283
D.Diag(diag::err_drv_unsupported_opt_for_target)
276284
<< A->getSpelling() << Triple.getTriple();
277285

286+
if (A->getOption().matches(options::OPT_mevex512) ||
287+
A->getOption().matches(options::OPT_mno_evex512))
288+
D.Diag(diag::warn_drv_deprecated_custom)
289+
<< Name << "because AVX10/256 is not supported and will be removed";
290+
278291
if (A->getOption().matches(options::OPT_mapx_features_EQ) ||
279292
A->getOption().matches(options::OPT_mno_apx_features_EQ)) {
280293

clang/test/Driver/x86-target-features.c

+18-16
Original file line numberDiff line numberDiff line change
@@ -390,31 +390,33 @@
390390
// AVXVNNIINT16: "-target-feature" "+avxvnniint16"
391391
// NO-AVXVNNIINT16: "-target-feature" "-avxvnniint16"
392392

393-
// RUN: %clang --target=i386 -mevex512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=EVEX512 %s
394-
// RUN: %clang --target=i386 -mno-evex512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-EVEX512 %s
395-
// EVEX512: "-target-feature" "+evex512"
396-
// NO-EVEX512: "-target-feature" "-evex512"
397-
398-
// RUN: not %clang --target=i386 -march=i386 -mavx10.1 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=UNSUPPORT-AVX10 %s
399-
// RUN: not %clang --target=i386 -march=i386 -mno-avx10.1 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=UNSUPPORT-AVX10 %s
400-
// RUN: %clang --target=i386 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_256 %s
401-
// RUN: %clang --target=i386 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_512 %s
393+
// RUN: %clang --target=i386 -mevex512 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=EVEX512,WARN-EVEX512 %s
394+
// RUN: %clang --target=i386 -mno-evex512 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=NO-EVEX512,WARN-EVEX512 %s
395+
// RUN: %clang --target=i386 -march=i386 -mavx10.1 %s -### -o %t.o 2>&1 -Werror | FileCheck -check-prefix=AVX10_1_512 %s
396+
// RUN: %clang --target=i386 -march=i386 -mno-avx10.1 %s -### -o %t.o 2>&1 -Werror | FileCheck -check-prefix=NO-AVX10_1 %s
397+
// RUN: %clang --target=i386 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10_1_256,WARN-AVX10-256 %s
398+
// RUN: %clang --target=i386 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10_1_512,WARN-AVX10-512 %s
402399
// RUN: %clang --target=i386 -mavx10.1-256 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_512 %s
403400
// RUN: %clang --target=i386 -mavx10.1-512 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_256 %s
404401
// RUN: not %clang --target=i386 -march=i386 -mavx10.1-128 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
405402
// RUN: not %clang --target=i386 -march=i386 -mavx10.a-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
406403
// RUN: not %clang --target=i386 -march=i386 -mavx10.1024-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
407404
// RUN: %clang --target=i386 -march=i386 -mavx10.1-256 -mavx512f %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10-AVX512 %s
408405
// RUN: %clang --target=i386 -march=i386 -mavx10.1-256 -mno-avx512f %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10-AVX512 %s
409-
// RUN: %clang --target=i386 -march=i386 -mavx10.1-256 -mevex512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10-EVEX512 %s
410-
// RUN: %clang --target=i386 -march=i386 -mavx10.1-256 -mno-evex512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10-EVEX512 %s
411-
// RUN: %clang --target=i386 -mavx10.2 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_2_512 %s
412-
// RUN: %clang --target=i386 -mno-avx10.2 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-AVX10_2 %s
413-
// RUN: %clang --target=i386 -mavx10.2-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_2_256 %s
414-
// RUN: %clang --target=i386 -mavx10.2-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_2_512 %s
406+
// RUN: %clang --target=i386 -march=i386 -mavx10.1-256 -mevex512 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10-EVEX512,WARN-EVEX512 %s
407+
// RUN: %clang --target=i386 -march=i386 -mavx10.1-256 -mno-evex512 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10-EVEX512,WARN-EVEX512 %s
408+
// RUN: %clang --target=i386 -mavx10.2 %s -### -o %t.o 2>&1 -Werror | FileCheck -check-prefix=AVX10_2_512 %s
409+
// RUN: %clang --target=i386 -mno-avx10.2 %s -### -o %t.o 2>&1 -Werror | FileCheck -check-prefix=NO-AVX10_2 %s
410+
// RUN: %clang --target=i386 -mavx10.2-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10_2_256,WARN-AVX10-256 %s
411+
// RUN: %clang --target=i386 -mavx10.2-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10_2_512,WARN-AVX10-512 %s
415412
// RUN: %clang --target=i386 -mavx10.2-256 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10_2_256,AVX10_1_512 %s
416413
// RUN: %clang --target=i386 -mavx10.2-512 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefixes=AVX10_2_512,AVX10_1_256 %s
417-
// UNSUPPORT-AVX10: error: unsupported option '-m{{.*}}avx10.1' for target 'i386'
414+
// WARN-EVEX512: warning: argument '{{.*}}evex512' is deprecated, because AVX10/256 is not supported and will be removed [-Wdeprecated]
415+
// WARN-AVX10-256: warning: argument 'avx10.{{.*}}-256' is deprecated, because AVX10/256 is not supported and will be removed [-Wdeprecated]
416+
// WARN-AVX10-512: warning: argument 'avx10.{{.*}}-512' is deprecated, use 'avx10.{{.*}}' instead [-Wdeprecated]
417+
// EVEX512: "-target-feature" "+evex512"
418+
// NO-EVEX512: "-target-feature" "-evex512"
419+
// NO-AVX10_1: "-target-feature" "-avx10.1-256"
418420
// NO-AVX10_2: "-target-feature" "-avx10.2-256"
419421
// AVX10_2_256: "-target-feature" "+avx10.2-256"
420422
// AVX10_2_512: "-target-feature" "+avx10.2-512"

0 commit comments

Comments
 (0)