Skip to content

Commit f6290e0

Browse files
authored
[NFC][FMV] Add tests to demonstrate feature priorities. (#79455)
Adds tests showing that we select function version according to the highest feature priority. This will make the changes introduced by #79316 more evident.
1 parent 8a4cb7b commit f6290e0

File tree

1 file changed

+68
-2
lines changed

1 file changed

+68
-2
lines changed

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

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ inline int __attribute__((target_version("sve2-aes+sve2-sha3"))) fmv_inline(void
3636
inline int __attribute__((target_version("sve2+sve2-pmull128+sve2-bitperm"))) fmv_inline(void) { return 9; }
3737
inline int __attribute__((target_version("sve2-sm4+memtag2"))) fmv_inline(void) { return 10; }
3838
inline int __attribute__((target_version("memtag3+rcpc3+mops"))) fmv_inline(void) { return 11; }
39+
inline int __attribute__((target_version("aes+dotprod"))) fmv_inline(void) { return 13; }
40+
inline int __attribute__((target_version("simd+fp16fml"))) fmv_inline(void) { return 14; }
41+
inline int __attribute__((target_version("fp+sm4"))) fmv_inline(void) { return 15; }
42+
inline int __attribute__((target_version("lse+rdm"))) fmv_inline(void) { return 16; }
3943
inline int __attribute__((target_version("default"))) fmv_inline(void) { return 3; }
4044

4145
__attribute__((target_version("ls64"))) int fmv_e(void);
@@ -359,6 +363,38 @@ int hoo(void) {
359363
// CHECK: resolver_return21:
360364
// CHECK-NEXT: ret ptr @fmv_inline._Mdpb2Mjscvt
361365
// CHECK: resolver_else22:
366+
// CHECK-NEXT: [[TMP48:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
367+
// CHECK-NEXT: [[TMP49:%.*]] = and i64 [[TMP48]], 16400
368+
// CHECK-NEXT: [[TMP50:%.*]] = icmp eq i64 [[TMP49]], 16400
369+
// CHECK-NEXT: [[TMP51:%.*]] = and i1 true, [[TMP50]]
370+
// CHECK-NEXT: br i1 [[TMP51]], label [[RESOLVER_RETURN23:%.*]], label [[RESOLVER_ELSE24:%.*]]
371+
// CHECK: resolver_return23:
372+
// CHECK-NEXT: ret ptr @fmv_inline._MdotprodMaes
373+
// CHECK: resolver_else24:
374+
// CHECK-NEXT: [[TMP52:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
375+
// CHECK-NEXT: [[TMP53:%.*]] = and i64 [[TMP52]], 8
376+
// CHECK-NEXT: [[TMP54:%.*]] = icmp eq i64 [[TMP53]], 8
377+
// CHECK-NEXT: [[TMP55:%.*]] = and i1 true, [[TMP54]]
378+
// CHECK-NEXT: br i1 [[TMP55]], label [[RESOLVER_RETURN25:%.*]], label [[RESOLVER_ELSE26:%.*]]
379+
// CHECK: resolver_return25:
380+
// CHECK-NEXT: ret ptr @fmv_inline._Mfp16fmlMsimd
381+
// CHECK: resolver_else26:
382+
// CHECK-NEXT: [[TMP56:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
383+
// CHECK-NEXT: [[TMP57:%.*]] = and i64 [[TMP56]], 32
384+
// CHECK-NEXT: [[TMP58:%.*]] = icmp eq i64 [[TMP57]], 32
385+
// CHECK-NEXT: [[TMP59:%.*]] = and i1 true, [[TMP58]]
386+
// CHECK-NEXT: br i1 [[TMP59]], label [[RESOLVER_RETURN27:%.*]], label [[RESOLVER_ELSE28:%.*]]
387+
// CHECK: resolver_return27:
388+
// CHECK-NEXT: ret ptr @fmv_inline._Msm4Mfp
389+
// CHECK: resolver_else28:
390+
// CHECK-NEXT: [[TMP60:%.*]] = load i64, ptr @__aarch64_cpu_features, align 8
391+
// CHECK-NEXT: [[TMP61:%.*]] = and i64 [[TMP60]], 192
392+
// CHECK-NEXT: [[TMP62:%.*]] = icmp eq i64 [[TMP61]], 192
393+
// CHECK-NEXT: [[TMP63:%.*]] = and i1 true, [[TMP62]]
394+
// CHECK-NEXT: br i1 [[TMP63]], label [[RESOLVER_RETURN29:%.*]], label [[RESOLVER_ELSE30:%.*]]
395+
// CHECK: resolver_return29:
396+
// CHECK-NEXT: ret ptr @fmv_inline._MrdmMlse
397+
// CHECK: resolver_else30:
362398
// CHECK-NEXT: ret ptr @fmv_inline.default
363399
//
364400
//
@@ -616,6 +652,34 @@ int hoo(void) {
616652
//
617653
//
618654
// CHECK: Function Attrs: noinline nounwind optnone
655+
// CHECK-LABEL: define {{[^@]+}}@fmv_inline._MdotprodMaes
656+
// CHECK-SAME: () #[[ATTR6]] {
657+
// CHECK-NEXT: entry:
658+
// CHECK-NEXT: ret i32 13
659+
//
660+
//
661+
// CHECK: Function Attrs: noinline nounwind optnone
662+
// CHECK-LABEL: define {{[^@]+}}@fmv_inline._Mfp16fmlMsimd
663+
// CHECK-SAME: () #[[ATTR7]] {
664+
// CHECK-NEXT: entry:
665+
// CHECK-NEXT: ret i32 14
666+
//
667+
//
668+
// CHECK: Function Attrs: noinline nounwind optnone
669+
// CHECK-LABEL: define {{[^@]+}}@fmv_inline._Msm4Mfp
670+
// CHECK-SAME: () #[[ATTR24:[0-9]+]] {
671+
// CHECK-NEXT: entry:
672+
// CHECK-NEXT: ret i32 15
673+
//
674+
//
675+
// CHECK: Function Attrs: noinline nounwind optnone
676+
// CHECK-LABEL: define {{[^@]+}}@fmv_inline._MrdmMlse
677+
// CHECK-SAME: () #[[ATTR25:[0-9]+]] {
678+
// CHECK-NEXT: entry:
679+
// CHECK-NEXT: ret i32 16
680+
//
681+
//
682+
// CHECK: Function Attrs: noinline nounwind optnone
619683
// CHECK-LABEL: define {{[^@]+}}@fmv_inline.default
620684
// CHECK-SAME: () #[[ATTR2]] {
621685
// CHECK-NEXT: entry:
@@ -624,7 +688,7 @@ int hoo(void) {
624688
//
625689
// CHECK: Function Attrs: noinline nounwind optnone
626690
// CHECK-LABEL: define {{[^@]+}}@fmv_d._Msb
627-
// CHECK-SAME: () #[[ATTR24:[0-9]+]] {
691+
// CHECK-SAME: () #[[ATTR26:[0-9]+]] {
628692
// CHECK-NEXT: entry:
629693
// CHECK-NEXT: ret i32 0
630694
//
@@ -769,7 +833,9 @@ int hoo(void) {
769833
// CHECK: attributes #[[ATTR21]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+ls64,+neon,+sve,+sve2,+sve2-aes,+sve2-bitperm" }
770834
// CHECK: attributes #[[ATTR22]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+ls64,+mte,+neon,+sve,+sve2,+sve2-sm4" }
771835
// CHECK: attributes #[[ATTR23]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fullfp16,+ls64,+mops,+mte,+rcpc,+rcpc3" }
772-
// CHECK: attributes #[[ATTR24]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fullfp16,+ls64,+sb" }
836+
// CHECK: attributes #[[ATTR24]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+ls64,+neon,+sm4" }
837+
// CHECK: attributes #[[ATTR25]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fp-armv8,+fullfp16,+ls64,+lse,+neon,+rdm" }
838+
// CHECK: attributes #[[ATTR26]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+fullfp16,+ls64,+sb" }
773839
//.
774840
// CHECK-NOFMV: attributes #[[ATTR0]] = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="-fmv" }
775841
// CHECK-NOFMV: attributes #[[ATTR1:[0-9]+]] = { "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="-fmv" }

0 commit comments

Comments
 (0)