1 ; RUN: llc -mtriple aarch64 -mattr=+sve -asm-verbose=0 < %s | FileCheck %s
2 ; RUN: opt -mtriple=aarch64 -codegenprepare -S < %s | llc -mtriple=aarch64 -mattr=+sve -asm-verbose=0 | FileCheck %s
8 ; CHECK-LABEL: rdvl_i8:
11 define i8 @rdvl_i8() nounwind {
12 %vscale = call i8 @llvm.vscale.i8()
13 %1 = mul nsw i8 %vscale, 16
17 ; CHECK-LABEL: rdvl_i16:
20 define i16 @rdvl_i16() nounwind {
21 %vscale = call i16 @llvm.vscale.i16()
22 %1 = mul nsw i16 %vscale, 16
26 ; CHECK-LABEL: rdvl_i32:
29 define i32 @rdvl_i32() nounwind {
30 %vscale = call i32 @llvm.vscale.i32()
31 %1 = mul nsw i32 %vscale, 16
35 ; CHECK-LABEL: rdvl_i64:
38 define i64 @rdvl_i64() nounwind {
39 %vscale = call i64 @llvm.vscale.i64()
40 %1 = mul nsw i64 %vscale, 16
44 ; CHECK-LABEL: rdvl_const:
47 define i32 @rdvl_const() nounwind {
48 ret i32 mul nsw (i32 ptrtoint (<vscale x 1 x i8>* getelementptr (<vscale x 1 x i8>, <vscale x 1 x i8>* null, i64 1) to i32), i32 16)
51 ; CHECK-LABEL: rdvl_const_opaque_ptr:
54 define i32 @rdvl_const_opaque_ptr() nounwind {
55 ret i32 mul nsw (i32 ptrtoint (ptr getelementptr (<vscale x 1 x i8>, ptr null, i64 1) to i32), i32 16)
58 define i32 @vscale_1() nounwind {
59 ; CHECK-LABEL: vscale_1:
60 ; CHECK: rdvl [[TMP:x[0-9]+]], #1
61 ; CHECK-NEXT: lsr x0, [[TMP]], #4
63 %vscale = call i32 @llvm.vscale.i32()
67 define i32 @vscale_neg1() nounwind {
68 ; CHECK-LABEL: vscale_neg1:
69 ; CHECK: rdvl [[TMP:x[0-9]+]], #-1
70 ; CHECK-NEXT: asr x0, [[TMP]], #4
72 %vscale = call i32 @llvm.vscale.i32()
73 %neg = mul nsw i32 -1, %vscale
77 ; CHECK-LABEL: rdvl_3:
78 ; CHECK: rdvl [[VL_B:x[0-9]+]], #1
79 ; CHECK-NEXT: lsr [[VL_Q:x[0-9]+]], [[VL_B]], #4
80 ; CHECK-NEXT: mov w[[MUL:[0-9]+]], #3
81 ; CHECK-NEXT: mul x0, [[VL_Q]], x[[MUL]]
83 define i32 @rdvl_3() nounwind {
84 %vscale = call i32 @llvm.vscale.i32()
85 %1 = mul nsw i32 %vscale, 3
90 ; CHECK-LABEL: rdvl_min:
91 ; CHECK: rdvl x0, #-32
93 define i32 @rdvl_min() nounwind {
94 %vscale = call i32 @llvm.vscale.i32()
95 %1 = mul nsw i32 %vscale, -512
99 ; CHECK-LABEL: rdvl_max:
100 ; CHECK: rdvl x0, #31
102 define i32 @rdvl_max() nounwind {
103 %vscale = call i32 @llvm.vscale.i32()
104 %1 = mul nsw i32 %vscale, 496
113 ; CHECK: cnth x0{{$}}
115 define i32 @cnth() nounwind {
116 %vscale = call i32 @llvm.vscale.i32()
117 %1 = shl nsw i32 %vscale, 3
121 ; CHECK-LABEL: cnth_max:
122 ; CHECK: cnth x0, all, mul #15
124 define i32 @cnth_max() nounwind {
125 %vscale = call i32 @llvm.vscale.i32()
126 %1 = mul nsw i32 %vscale, 120
130 ; CHECK-LABEL: cnth_neg:
131 ; CHECK: cnth [[CNT:x[0-9]+]]
132 ; CHECK: neg x0, [[CNT]]
134 define i32 @cnth_neg() nounwind {
135 %vscale = call i32 @llvm.vscale.i32()
136 %1 = mul nsw i32 %vscale, -8
145 ; CHECK: cntw x0{{$}}
147 define i32 @cntw() nounwind {
148 %vscale = call i32 @llvm.vscale.i32()
149 %1 = shl nsw i32 %vscale, 2
153 ; CHECK-LABEL: cntw_max:
154 ; CHECK: cntw x0, all, mul #15
156 define i32 @cntw_max() nounwind {
157 %vscale = call i32 @llvm.vscale.i32()
158 %1 = mul nsw i32 %vscale, 60
162 ; CHECK-LABEL: cntw_neg:
163 ; CHECK: cntw [[CNT:x[0-9]+]]
164 ; CHECK: neg x0, [[CNT]]
166 define i32 @cntw_neg() nounwind {
167 %vscale = call i32 @llvm.vscale.i32()
168 %1 = mul nsw i32 %vscale, -4
177 ; CHECK: cntd x0{{$}}
179 define i32 @cntd() nounwind {
180 %vscale = call i32 @llvm.vscale.i32()
181 %1 = shl nsw i32 %vscale, 1
185 ; CHECK-LABEL: cntd_max:
186 ; CHECK: cntd x0, all, mul #15
188 define i32 @cntd_max() nounwind {
189 %vscale = call i32 @llvm.vscale.i32()
190 %1 = mul nsw i32 %vscale, 30
194 ; CHECK-LABEL: cntd_neg:
195 ; CHECK: cntd [[CNT:x[0-9]+]]
196 ; CHECK: neg x0, [[CNT]]
198 define i32 @cntd_neg() nounwind {
199 %vscale = call i32 @llvm.vscale.i32()
200 %1 = mul nsw i32 %vscale, -2
204 declare i8 @llvm.vscale.i8()
205 declare i16 @llvm.vscale.i16()
206 declare i32 @llvm.vscale.i32()
207 declare i64 @llvm.vscale.i64()