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_svcntd()7 uint64_t test_svcntd()
8 {
9   // CHECK-LABEL: test_svcntd
10   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.vscale.i64()
11   // CHECK-NEXT: %[[RET:.*]] = shl i64 %[[INTRINSIC]], 1
12   // CHECK: ret i64 %[[RET]]
13   return svcntd();
14 }
15 
test_svcntd_pat()16 uint64_t test_svcntd_pat()
17 {
18   // CHECK-LABEL: test_svcntd_pat
19   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 0)
20   // CHECK: ret i64 %[[INTRINSIC]]
21   return svcntd_pat(SV_POW2);
22 }
23 
test_svcntd_pat_1()24 uint64_t test_svcntd_pat_1()
25 {
26   // CHECK-LABEL: test_svcntd_pat_1
27   // CHECK: ret i64 1
28   return svcntd_pat(SV_VL1);
29 }
30 
test_svcntd_pat_2()31 uint64_t test_svcntd_pat_2()
32 {
33   // CHECK-LABEL: test_svcntd_pat_2
34   // CHECK: ret i64 2
35   return svcntd_pat(SV_VL2);
36 }
37 
test_svcntd_pat_3()38 uint64_t test_svcntd_pat_3()
39 {
40   // CHECK-LABEL: test_svcntd_pat_3
41   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 3)
42   // CHECK: ret i64 %[[INTRINSIC]]
43   return svcntd_pat(SV_VL3);
44 }
45 
test_svcntd_pat_4()46 uint64_t test_svcntd_pat_4()
47 {
48   // CHECK-LABEL: test_svcntd_pat_4
49   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 4)
50   // CHECK: ret i64 %[[INTRINSIC]]
51   return svcntd_pat(SV_VL4);
52 }
53 
test_svcntd_pat_5()54 uint64_t test_svcntd_pat_5()
55 {
56   // CHECK-LABEL: test_svcntd_pat_5
57   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 5)
58   // CHECK: ret i64 %[[INTRINSIC]]
59   return svcntd_pat(SV_VL5);
60 }
61 
test_svcntd_pat_6()62 uint64_t test_svcntd_pat_6()
63 {
64   // CHECK-LABEL: test_svcntd_pat_6
65   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 6)
66   // CHECK: ret i64 %[[INTRINSIC]]
67   return svcntd_pat(SV_VL6);
68 }
69 
test_svcntd_pat_7()70 uint64_t test_svcntd_pat_7()
71 {
72   // CHECK-LABEL: test_svcntd_pat_7
73   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 7)
74   // CHECK: ret i64 %[[INTRINSIC]]
75   return svcntd_pat(SV_VL7);
76 }
77 
test_svcntd_pat_8()78 uint64_t test_svcntd_pat_8()
79 {
80   // CHECK-LABEL: test_svcntd_pat_8
81   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 8)
82   // CHECK: ret i64 %[[INTRINSIC]]
83   return svcntd_pat(SV_VL8);
84 }
85 
test_svcntd_pat_9()86 uint64_t test_svcntd_pat_9()
87 {
88   // CHECK-LABEL: test_svcntd_pat_9
89   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 9)
90   // CHECK: ret i64 %[[INTRINSIC]]
91   return svcntd_pat(SV_VL16);
92 }
93 
test_svcntd_pat_10()94 uint64_t test_svcntd_pat_10()
95 {
96   // CHECK-LABEL: test_svcntd_pat_10
97   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 10)
98   // CHECK: ret i64 %[[INTRINSIC]]
99   return svcntd_pat(SV_VL32);
100 }
101 
test_svcntd_pat_11()102 uint64_t test_svcntd_pat_11()
103 {
104   // CHECK-LABEL: test_svcntd_pat_11
105   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 11)
106   // CHECK: ret i64 %[[INTRINSIC]]
107   return svcntd_pat(SV_VL64);
108 }
109 
test_svcntd_pat_12()110 uint64_t test_svcntd_pat_12()
111 {
112   // CHECK-LABEL: test_svcntd_pat_12
113   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 12)
114   // CHECK: ret i64 %[[INTRINSIC]]
115   return svcntd_pat(SV_VL128);
116 }
117 
test_svcntd_pat_13()118 uint64_t test_svcntd_pat_13()
119 {
120   // CHECK-LABEL: test_svcntd_pat_13
121   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 13)
122   // CHECK: ret i64 %[[INTRINSIC]]
123   return svcntd_pat(SV_VL256);
124 }
125 
test_svcntd_pat_14()126 uint64_t test_svcntd_pat_14()
127 {
128   // CHECK-LABEL: test_svcntd_pat_14
129   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 29)
130   // CHECK: ret i64 %[[INTRINSIC]]
131   return svcntd_pat(SV_MUL4);
132 }
133 
test_svcntd_pat_15()134 uint64_t test_svcntd_pat_15()
135 {
136   // CHECK-LABEL: test_svcntd_pat_15
137   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.aarch64.sve.cntd(i32 30)
138   // CHECK: ret i64 %[[INTRINSIC]]
139   return svcntd_pat(SV_MUL3);
140 }
141 
test_svcntd_pat_16()142 uint64_t test_svcntd_pat_16()
143 {
144   // CHECK-LABEL: test_svcntd_pat_16
145   // CHECK: %[[INTRINSIC:.*]] = call i64 @llvm.vscale.i64()
146   // CHECK-NEXT: %[[RET:.*]] = shl i64 %[[INTRINSIC]], 1
147   // CHECK: ret i64 %[[RET]]
148   return svcntd_pat(SV_ALL);
149 }
150