1 // REQUIRES: aarch64-registered-target
2 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
4 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null
5 #include <arm_sve.h>
6 
test_svcnth()7 uint64_t test_svcnth()
8 {
9   // CHECK-LABEL: test_svcnth
10   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.vscale.i64()
11   // CHECK-NEXT: %[[RET:.*]] = shl i64 %[[INTRINSIC]], 3
12   // CHECK: ret i64 %[[RET]]
13   return svcnth();
14 }
15 
test_svcnth_pat()16 uint64_t test_svcnth_pat()
17 {
18   // CHECK-LABEL: test_svcnth_pat
19   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cnth(i32 0)
20   // CHECK: ret i64 %[[INTRINSIC]]
21   return svcnth_pat(SV_POW2);
22 }
23 
test_svcnth_pat_1()24 uint64_t test_svcnth_pat_1()
25 {
26   // CHECK-LABEL: test_svcnth_pat_1
27   // CHECK: ret i64 1
28   return svcnth_pat(SV_VL1);
29 }
30 
test_svcnth_pat_2()31 uint64_t test_svcnth_pat_2()
32 {
33   // CHECK-LABEL: test_svcnth_pat_2
34   // CHECK: ret i64 2
35   return svcnth_pat(SV_VL2);
36 }
37 
test_svcnth_pat_3()38 uint64_t test_svcnth_pat_3()
39 {
40   // CHECK-LABEL: test_svcnth_pat_3
41   // CHECK: ret i64 3
42   return svcnth_pat(SV_VL3);
43 }
44 
test_svcnth_pat_4()45 uint64_t test_svcnth_pat_4()
46 {
47   // CHECK-LABEL: test_svcnth_pat_4
48   // CHECK: ret i64 4
49   return svcnth_pat(SV_VL4);
50 }
51 
test_svcnth_pat_5()52 uint64_t test_svcnth_pat_5()
53 {
54   // CHECK-LABEL: test_svcnth_pat_5
55   // CHECK: ret i64 5
56   return svcnth_pat(SV_VL5);
57 }
58 
test_svcnth_pat_6()59 uint64_t test_svcnth_pat_6()
60 {
61   // CHECK-LABEL: test_svcnth_pat_6
62   // CHECK: ret i64 6
63   return svcnth_pat(SV_VL6);
64 }
65 
test_svcnth_pat_7()66 uint64_t test_svcnth_pat_7()
67 {
68   // CHECK-LABEL: test_svcnth_pat_7
69   // CHECK: ret i64 7
70   return svcnth_pat(SV_VL7);
71 }
72 
test_svcnth_pat_8()73 uint64_t test_svcnth_pat_8()
74 {
75   // CHECK-LABEL: test_svcnth_pat_8
76   // CHECK: ret i64 8
77   return svcnth_pat(SV_VL8);
78 }
79 
test_svcnth_pat_9()80 uint64_t test_svcnth_pat_9()
81 {
82   // CHECK-LABEL: test_svcnth_pat_9
83   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cnth(i32 9)
84   // CHECK: ret i64 %[[INTRINSIC]]
85   return svcnth_pat(SV_VL16);
86 }
87 
test_svcnth_pat_10()88 uint64_t test_svcnth_pat_10()
89 {
90   // CHECK-LABEL: test_svcnth_pat_10
91   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cnth(i32 10)
92   // CHECK: ret i64 %[[INTRINSIC]]
93   return svcnth_pat(SV_VL32);
94 }
95 
test_svcnth_pat_11()96 uint64_t test_svcnth_pat_11()
97 {
98   // CHECK-LABEL: test_svcnth_pat_11
99   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cnth(i32 11)
100   // CHECK: ret i64 %[[INTRINSIC]]
101   return svcnth_pat(SV_VL64);
102 }
103 
test_svcnth_pat_12()104 uint64_t test_svcnth_pat_12()
105 {
106   // CHECK-LABEL: test_svcnth_pat_12
107   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cnth(i32 12)
108   // CHECK: ret i64 %[[INTRINSIC]]
109   return svcnth_pat(SV_VL128);
110 }
111 
test_svcnth_pat_13()112 uint64_t test_svcnth_pat_13()
113 {
114   // CHECK-LABEL: test_svcnth_pat_13
115   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cnth(i32 13)
116   // CHECK: ret i64 %[[INTRINSIC]]
117   return svcnth_pat(SV_VL256);
118 }
119 
test_svcnth_pat_14()120 uint64_t test_svcnth_pat_14()
121 {
122   // CHECK-LABEL: test_svcnth_pat_14
123   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cnth(i32 29)
124   // CHECK: ret i64 %[[INTRINSIC]]
125   return svcnth_pat(SV_MUL4);
126 }
127 
test_svcnth_pat_15()128 uint64_t test_svcnth_pat_15()
129 {
130   // CHECK-LABEL: test_svcnth_pat_15
131   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cnth(i32 30)
132   // CHECK: ret i64 %[[INTRINSIC]]
133   return svcnth_pat(SV_MUL3);
134 }
135 
test_svcnth_pat_16()136 uint64_t test_svcnth_pat_16()
137 {
138   // CHECK-LABEL: test_svcnth_pat_16
139   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.vscale.i64()
140   // CHECK-NEXT: %[[RET:.*]] = shl i64 %[[INTRINSIC]], 3
141   // CHECK: ret i64 %[[RET]]
142   return svcnth_pat(SV_ALL);
143 }
144