Skip to content

Commit 99f3ed7

Browse files
authored
[X86][AVX10] Disable m[no-]avx10.1 and switch m[no-]avx10.2 to alias of 512 bit options (llvm#124511) (llvm#125057)
Per the feedback we got, we’d like to switch m[no-]avx10.2 to alias of 512 bit options and disable m[no-]avx10.1 due to they were alias of 256 bit options. We also change -mno-avx10.[1,2]-512 to alias of 256 bit options to disable both 256 and 512 instructions. Cherry-pick from llvm@9ebfee9
1 parent c08c9f9 commit 99f3ed7

File tree

5 files changed

+28
-20
lines changed

5 files changed

+28
-20
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,10 @@ X86 Support
11651165
- Support ISA of ``MOVRS``.
11661166

11671167
- Supported ``-march/tune=diamondrapids``
1168+
- Disable ``-m[no-]avx10.1`` and switch ``-m[no-]avx10.2`` to alias of 512 bit
1169+
options.
1170+
- Change ``-mno-avx10.1-512`` to alias of ``-mno-avx10.1-256`` to disable both
1171+
256 and 512 bit instructions.
11681172

11691173
Arm and AArch64 Support
11701174
^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6441,15 +6441,13 @@ def mno_avx : Flag<["-"], "mno-avx">, Group<m_x86_Features_Group>;
64416441
def mavx10_1_256 : Flag<["-"], "mavx10.1-256">, Group<m_x86_AVX10_Features_Group>;
64426442
def mno_avx10_1_256 : Flag<["-"], "mno-avx10.1-256">, Group<m_x86_AVX10_Features_Group>;
64436443
def mavx10_1_512 : Flag<["-"], "mavx10.1-512">, Group<m_x86_AVX10_Features_Group>;
6444-
def mno_avx10_1_512 : Flag<["-"], "mno-avx10.1-512">, Group<m_x86_AVX10_Features_Group>;
6445-
def mavx10_1 : Flag<["-"], "mavx10.1">, Alias<mavx10_1_256>;
6446-
def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Alias<mno_avx10_1_256>;
6444+
def mno_avx10_1_512 : Flag<["-"], "mno-avx10.1-512">, Alias<mno_avx10_1_256>;
6445+
def mavx10_1 : Flag<["-"], "mavx10.1">, Flags<[Unsupported]>;
6446+
def mno_avx10_1 : Flag<["-"], "mno-avx10.1">, Flags<[Unsupported]>;
64476447
def mavx10_2_256 : Flag<["-"], "mavx10.2-256">, Group<m_x86_AVX10_Features_Group>;
6448-
def mno_avx10_2_256 : Flag<["-"], "mno-avx10.2-256">, Group<m_x86_AVX10_Features_Group>;
64496448
def mavx10_2_512 : Flag<["-"], "mavx10.2-512">, Group<m_x86_AVX10_Features_Group>;
6450-
def mno_avx10_2_512 : Flag<["-"], "mno-avx10.2-512">, Group<m_x86_AVX10_Features_Group>;
6451-
def mavx10_2 : Flag<["-"], "mavx10.2">, Alias<mavx10_2_256>;
6452-
def mno_avx10_2 : Flag<["-"], "mno-avx10.2">, Alias<mno_avx10_2_256>;
6449+
def mavx10_2 : Flag<["-"], "mavx10.2">, Alias<mavx10_2_512>;
6450+
def mno_avx10_2 : Flag<["-"], "mno-avx10.2">, Group<m_x86_AVX10_Features_Group>;
64536451
def mavx2 : Flag<["-"], "mavx2">, Group<m_x86_Features_Group>;
64546452
def mno_avx2 : Flag<["-"], "mno-avx2">, Group<m_x86_Features_Group>;
64556453
def mavx512f : Flag<["-"], "mavx512f">, Group<m_x86_Features_Group>;

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,15 +237,18 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
237237

238238
bool IsNegative = Name.consume_front("no-");
239239

240-
#ifndef NDEBUG
241-
assert(Name.starts_with("avx10.") && "Invalid AVX10 feature name.");
242240
StringRef Version, Width;
243241
std::tie(Version, Width) = Name.substr(6).split('-');
242+
assert(Name.starts_with("avx10.") && "Invalid AVX10 feature name.");
244243
assert((Version == "1" || Version == "2") && "Invalid AVX10 feature name.");
245-
assert((Width == "256" || Width == "512") && "Invalid AVX10 feature name.");
246-
#endif
247244

248-
Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
245+
if (Width == "") {
246+
assert(IsNegative && "Only negative options can omit width.");
247+
Features.push_back(Args.MakeArgString("-" + Name + "-256"));
248+
} else {
249+
assert((Width == "256" || Width == "512") && "Invalid vector length.");
250+
Features.push_back(Args.MakeArgString((IsNegative ? "-" : "+") + Name));
251+
}
249252
}
250253

251254
// Now add any that the user explicitly requested on the command line,

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,23 +395,27 @@
395395
// EVEX512: "-target-feature" "+evex512"
396396
// NO-EVEX512: "-target-feature" "-evex512"
397397

398-
// RUN: %clang --target=i386 -mavx10.1 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_256 %s
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
399400
// RUN: %clang --target=i386 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_256 %s
400401
// RUN: %clang --target=i386 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_512 %s
401402
// RUN: %clang --target=i386 -mavx10.1-256 -mavx10.1-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_512 %s
402403
// RUN: %clang --target=i386 -mavx10.1-512 -mavx10.1-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_1_256 %s
403404
// RUN: not %clang --target=i386 -march=i386 -mavx10.1-128 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
404405
// RUN: not %clang --target=i386 -march=i386 -mavx10.a-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
405406
// RUN: not %clang --target=i386 -march=i386 -mavx10.1024-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=BAD-AVX10 %s
406-
// RUN: %clang --target=i386 -march=i386 -mavx10.1 -mavx512f %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10-AVX512 %s
407-
// RUN: %clang --target=i386 -march=i386 -mavx10.1 -mno-avx512f %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10-AVX512 %s
408-
// RUN: %clang --target=i386 -march=i386 -mavx10.1 -mevex512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10-EVEX512 %s
409-
// RUN: %clang --target=i386 -march=i386 -mavx10.1 -mno-evex512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10-EVEX512 %s
410-
// RUN: %clang --target=i386 -mavx10.2 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_2_256 %s
407+
// RUN: %clang --target=i386 -march=i386 -mavx10.1-256 -mavx512f %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10-AVX512 %s
408+
// 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
411413
// RUN: %clang --target=i386 -mavx10.2-256 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_2_256 %s
412414
// RUN: %clang --target=i386 -mavx10.2-512 %s -### -o %t.o 2>&1 | FileCheck -check-prefix=AVX10_2_512 %s
413415
// 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
414416
// 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'
418+
// NO-AVX10_2: "-target-feature" "-avx10.2-256"
415419
// AVX10_2_256: "-target-feature" "+avx10.2-256"
416420
// AVX10_2_512: "-target-feature" "+avx10.2-512"
417421
// AVX10_1_256: "-target-feature" "+avx10.1-256"

clang/test/Preprocessor/x86_target_features.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,10 +742,8 @@
742742
// AVXVNNIINT16NOAVX2-NOT: #define __AVX2__ 1
743743
// AVXVNNIINT16NOAVX2-NOT: #define __AVXVNNIINT16__ 1
744744

745-
// RUN: %clang -target i686-unknown-linux-gnu -march=atom -mavx10.1 -x c -E -dM -o - %s | FileCheck -check-prefix=AVX10_1_256 %s
746745
// RUN: %clang -target i686-unknown-linux-gnu -march=atom -mavx10.1-256 -x c -E -dM -o - %s | FileCheck -check-prefix=AVX10_1_256 %s
747746
// RUN: %clang -target i686-unknown-linux-gnu -march=atom -mavx10.1-256 -mno-avx512f -x c -E -dM -o - %s | FileCheck -check-prefix=AVX10_1_256 %s
748-
// RUN: %clang -target i686-unknown-linux-gnu -march=atom -mavx10.2 -x c -E -dM -o - %s | FileCheck -check-prefixes=AVX10_1_256,AVX10_2_256 %s
749747
// RUN: %clang -target i686-unknown-linux-gnu -march=atom -mavx10.2-256 -x c -E -dM -o - %s | FileCheck -check-prefixes=AVX10_1_256,AVX10_2_256 %s
750748
// AVX10_1_256-NOT: __AVX10_1_512__
751749
// AVX10_1_256: #define __AVX10_1__ 1
@@ -758,6 +756,7 @@
758756
// RUN: %clang -target i686-unknown-linux-gnu -march=atom -mavx10.1-512 -x c -E -dM -o - %s | FileCheck -check-prefix=AVX10_1_512 %s
759757
// RUN: %clang -target i686-unknown-linux-gnu -march=atom -mavx10.1-512 -mno-avx512f -x c -E -dM -o - %s | FileCheck -check-prefix=AVX10_1_512 %s
760758
// RUN: %clang -target i686-unknown-linux-gnu -march=atom -mavx10.1-512 -mno-evex512 -x c -E -dM -o - %s | FileCheck -check-prefix=AVX10_1_512 %s
759+
// RUN: %clang -target i686-unknown-linux-gnu -march=atom -mavx10.2 -x c -E -dM -o - %s | FileCheck -check-prefixes=AVX10_1_512,AVX10_2_512 %s
761760
// RUN: %clang -target i686-unknown-linux-gnu -march=atom -mavx10.2-512 -x c -E -dM -o - %s | FileCheck -check-prefixes=AVX10_1_512,AVX10_2_512 %s
762761
// AVX10_1_512: #define __AVX10_1_512__ 1
763762
// AVX10_1_512: #define __AVX10_1__ 1

0 commit comments

Comments
 (0)