Skip to content

Commit ea6cdb9

Browse files
authored
allow prefer 256 bit attribute target (#117092)
This allows `__attribute__((target("prefer-256-bit")))` / `__attribute__((target("no-prefer-256-bit")))` to create variants of a functions with 256/512 bit vector sizes within the same application.
1 parent c7d3859 commit ea6cdb9

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

clang/lib/Basic/Targets/X86.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ bool X86TargetInfo::isValidFeatureName(StringRef Name) const {
11621162
.Case("pconfig", true)
11631163
.Case("pku", true)
11641164
.Case("popcnt", true)
1165+
.Case("prefer-256-bit", true)
11651166
.Case("prefetchi", true)
11661167
.Case("prfchw", true)
11671168
.Case("ptwrite", true)

clang/test/CodeGen/attr-target-x86.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
// CHECK: define {{.*}}@f_x86_64_v4({{.*}} [[f_x86_64_v4:#[0-9]+]]
1919
// CHECK: define {{.*}}@f_avx10_1_256{{.*}} [[f_avx10_1_256:#[0-9]+]]
2020
// CHECK: define {{.*}}@f_avx10_1_512{{.*}} [[f_avx10_1_512:#[0-9]+]]
21+
// CHECK: define {{.*}}@f_prefer_256_bit({{.*}} [[f_prefer_256_bit:#[0-9]+]]
22+
// CHECK: define {{.*}}@f_no_prefer_256_bit({{.*}} [[f_no_prefer_256_bit:#[0-9]+]]
2123

2224
// CHECK: [[f_default]] = {{.*}}"target-cpu"="i686" "target-features"="+cmov,+cx8,+x87" "tune-cpu"="i686"
2325
void f_default(void) {}
@@ -103,3 +105,11 @@ void f_avx10_1_256(void) {}
103105
// CHECK: [[f_avx10_1_512]] = {{.*}}"target-cpu"="i686" "target-features"="+aes,+avx,+avx10.1-256,+avx10.1-512,+avx2,+avx512bf16,+avx512bitalg,+avx512bw,+avx512cd,+avx512dq,+avx512f,+avx512fp16,+avx512ifma,+avx512vbmi,+avx512vbmi2,+avx512vl,+avx512vnni,+avx512vpopcntdq,+cmov,+crc32,+cx8,+evex512,+f16c,+fma,+mmx,+pclmul,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+vaes,+vpclmulqdq,+x87,+xsave"
104106
__attribute__((target("avx10.1-512")))
105107
void f_avx10_1_512(void) {}
108+
109+
// CHECK: [[f_prefer_256_bit]] = {{.*}}"target-features"="{{.*}}+prefer-256-bit
110+
__attribute__((target("prefer-256-bit")))
111+
void f_prefer_256_bit(void) {}
112+
113+
// CHECK: [[f_no_prefer_256_bit]] = {{.*}}"target-features"="{{.*}}-prefer-256-bit
114+
__attribute__((target("no-prefer-256-bit")))
115+
void f_no_prefer_256_bit(void) {}

0 commit comments

Comments
 (0)