1 ; RUN: llc < %s -mtriple=ve-unknown-unknown | FileCheck %s
3 declare i128 @llvm.ctlz.i128(i128, i1)
4 declare i64 @llvm.ctlz.i64(i64, i1)
5 declare i32 @llvm.ctlz.i32(i32, i1)
6 declare i16 @llvm.ctlz.i16(i16, i1)
7 declare i8 @llvm.ctlz.i8(i8, i1)
9 define i128 @func128(i128 %p){
10 ; CHECK-LABEL: func128:
12 ; CHECK-NEXT: ldz %s2, %s1
13 ; CHECK-NEXT: ldz %s0, %s0
14 ; CHECK-NEXT: lea %s0, 64(, %s0)
15 ; CHECK-NEXT: cmov.l.ne %s0, %s2, %s1
16 ; CHECK-NEXT: or %s1, 0, (0)1
17 ; CHECK-NEXT: b.l.t (, %s10)
18 %r = tail call i128 @llvm.ctlz.i128(i128 %p, i1 true)
22 define i64 @func64(i64 %p) {
23 ; CHECK-LABEL: func64:
25 ; CHECK-NEXT: ldz %s0, %s0
26 ; CHECK-NEXT: b.l.t (, %s10)
27 %r = tail call i64 @llvm.ctlz.i64(i64 %p, i1 true)
31 define signext i32 @func32s(i32 signext %p) {
32 ; CHECK-LABEL: func32s:
34 ; CHECK-NEXT: and %s0, %s0, (32)0
35 ; CHECK-NEXT: ldz %s0, %s0
36 ; CHECK-NEXT: lea %s0, -32(, %s0)
37 ; CHECK-NEXT: and %s0, %s0, (32)0
38 ; CHECK-NEXT: b.l.t (, %s10)
39 %r = tail call i32 @llvm.ctlz.i32(i32 %p, i1 true)
43 define zeroext i32 @func32z(i32 zeroext %p) {
44 ; CHECK-LABEL: func32z:
46 ; CHECK-NEXT: ldz %s0, %s0
47 ; CHECK-NEXT: lea %s0, -32(, %s0)
48 ; CHECK-NEXT: and %s0, %s0, (32)0
49 ; CHECK-NEXT: b.l.t (, %s10)
50 %r = tail call i32 @llvm.ctlz.i32(i32 %p, i1 true)
54 define signext i16 @func16s(i16 signext %p) {
55 ; CHECK-LABEL: func16s:
57 ; CHECK-NEXT: and %s0, %s0, (48)0
58 ; CHECK-NEXT: ldz %s0, %s0
59 ; CHECK-NEXT: lea %s0, -32(, %s0)
60 ; CHECK-NEXT: adds.w.sx %s0, -16, %s0
61 ; CHECK-NEXT: and %s0, %s0, (48)0
62 ; CHECK-NEXT: b.l.t (, %s10)
63 %r = tail call i16 @llvm.ctlz.i16(i16 %p, i1 true)
67 define zeroext i16 @func16z(i16 zeroext %p) {
68 ; CHECK-LABEL: func16z:
70 ; CHECK-NEXT: ldz %s0, %s0
71 ; CHECK-NEXT: lea %s0, -32(, %s0)
72 ; CHECK-NEXT: adds.w.sx %s0, -16, %s0
73 ; CHECK-NEXT: and %s0, %s0, (48)0
74 ; CHECK-NEXT: b.l.t (, %s10)
75 %r = tail call i16 @llvm.ctlz.i16(i16 %p, i1 true)
79 define signext i8 @func8s(i8 signext %p) {
80 ; CHECK-LABEL: func8s:
82 ; CHECK-NEXT: and %s0, %s0, (56)0
83 ; CHECK-NEXT: ldz %s0, %s0
84 ; CHECK-NEXT: lea %s0, -32(, %s0)
85 ; CHECK-NEXT: adds.w.sx %s0, -24, %s0
86 ; CHECK-NEXT: and %s0, %s0, (56)0
87 ; CHECK-NEXT: b.l.t (, %s10)
88 %r = tail call i8 @llvm.ctlz.i8(i8 %p, i1 true)
92 define zeroext i8 @func8z(i8 zeroext %p) {
93 ; CHECK-LABEL: func8z:
95 ; CHECK-NEXT: ldz %s0, %s0
96 ; CHECK-NEXT: lea %s0, -32(, %s0)
97 ; CHECK-NEXT: adds.w.sx %s0, -24, %s0
98 ; CHECK-NEXT: and %s0, %s0, (56)0
99 ; CHECK-NEXT: b.l.t (, %s10)
100 %r = tail call i8 @llvm.ctlz.i8(i8 %p, i1 true)
104 define i128 @func128i(){
105 ; CHECK-LABEL: func128i:
107 ; CHECK-NEXT: lea %s0, 112
108 ; CHECK-NEXT: or %s1, 0, (0)1
109 ; CHECK-NEXT: b.l.t (, %s10)
110 %r = tail call i128 @llvm.ctlz.i128(i128 65535, i1 true)
114 define i64 @func64i() {
115 ; CHECK-LABEL: func64i:
117 ; CHECK-NEXT: or %s0, 48, (0)1
118 ; CHECK-NEXT: b.l.t (, %s10)
119 %r = tail call i64 @llvm.ctlz.i64(i64 65535, i1 true)
123 define signext i32 @func32is() {
124 ; CHECK-LABEL: func32is:
126 ; CHECK-NEXT: or %s0, 16, (0)1
127 ; CHECK-NEXT: b.l.t (, %s10)
128 %r = tail call i32 @llvm.ctlz.i32(i32 65535, i1 true)
132 define zeroext i32 @func32iz() {
133 ; CHECK-LABEL: func32iz:
135 ; CHECK-NEXT: or %s0, 16, (0)1
136 ; CHECK-NEXT: b.l.t (, %s10)
137 %r = tail call i32 @llvm.ctlz.i32(i32 65535, i1 true)
141 define signext i16 @func16is() {
142 ; CHECK-LABEL: func16is:
144 ; CHECK-NEXT: or %s0, 8, (0)1
145 ; CHECK-NEXT: b.l.t (, %s10)
146 %r = tail call i16 @llvm.ctlz.i16(i16 255, i1 true)
150 define zeroext i16 @func16iz() {
151 ; CHECK-LABEL: func16iz:
153 ; CHECK-NEXT: or %s0, 8, (0)1
154 ; CHECK-NEXT: b.l.t (, %s10)
155 %r = tail call i16 @llvm.ctlz.i16(i16 255, i1 true)
159 define signext i8 @func8is() {
160 ; CHECK-LABEL: func8is:
162 ; CHECK-NEXT: or %s0, 0, (0)1
163 ; CHECK-NEXT: b.l.t (, %s10)
164 %r = tail call i8 @llvm.ctlz.i8(i8 255, i1 true)
168 define zeroext i8 @func8iz() {
169 ; CHECK-LABEL: func8iz:
171 ; CHECK-NEXT: or %s0, 0, (0)1
172 ; CHECK-NEXT: b.l.t (, %s10)
173 %r = tail call i8 @llvm.ctlz.i8(i8 255, i1 true)
177 define i128 @func128x(i128 %p){
178 ; CHECK-LABEL: func128x:
180 ; CHECK-NEXT: ldz %s2, %s1
181 ; CHECK-NEXT: ldz %s0, %s0
182 ; CHECK-NEXT: lea %s0, 64(, %s0)
183 ; CHECK-NEXT: cmov.l.ne %s0, %s2, %s1
184 ; CHECK-NEXT: or %s1, 0, (0)1
185 ; CHECK-NEXT: b.l.t (, %s10)
186 %r = tail call i128 @llvm.ctlz.i128(i128 %p, i1 false)
190 define i64 @func64x(i64 %p) {
191 ; CHECK-LABEL: func64x:
193 ; CHECK-NEXT: ldz %s0, %s0
194 ; CHECK-NEXT: b.l.t (, %s10)
195 %r = tail call i64 @llvm.ctlz.i64(i64 %p, i1 false)
199 define signext i32 @func32sx(i32 signext %p) {
200 ; CHECK-LABEL: func32sx:
202 ; CHECK-NEXT: and %s0, %s0, (32)0
203 ; CHECK-NEXT: ldz %s0, %s0
204 ; CHECK-NEXT: lea %s0, -32(, %s0)
205 ; CHECK-NEXT: and %s0, %s0, (32)0
206 ; CHECK-NEXT: b.l.t (, %s10)
207 %r = tail call i32 @llvm.ctlz.i32(i32 %p, i1 false)
211 define zeroext i32 @func32zx(i32 zeroext %p) {
212 ; CHECK-LABEL: func32zx:
214 ; CHECK-NEXT: ldz %s0, %s0
215 ; CHECK-NEXT: lea %s0, -32(, %s0)
216 ; CHECK-NEXT: and %s0, %s0, (32)0
217 ; CHECK-NEXT: b.l.t (, %s10)
218 %r = tail call i32 @llvm.ctlz.i32(i32 %p, i1 false)
222 define signext i16 @func16sx(i16 signext %p) {
223 ; CHECK-LABEL: func16sx:
225 ; CHECK-NEXT: and %s0, %s0, (48)0
226 ; CHECK-NEXT: ldz %s0, %s0
227 ; CHECK-NEXT: lea %s0, -32(, %s0)
228 ; CHECK-NEXT: adds.w.sx %s0, -16, %s0
229 ; CHECK-NEXT: and %s0, %s0, (48)0
230 ; CHECK-NEXT: b.l.t (, %s10)
231 %r = tail call i16 @llvm.ctlz.i16(i16 %p, i1 false)
235 define zeroext i16 @func16zx(i16 zeroext %p) {
236 ; CHECK-LABEL: func16zx:
238 ; CHECK-NEXT: ldz %s0, %s0
239 ; CHECK-NEXT: lea %s0, -32(, %s0)
240 ; CHECK-NEXT: adds.w.sx %s0, -16, %s0
241 ; CHECK-NEXT: and %s0, %s0, (48)0
242 ; CHECK-NEXT: b.l.t (, %s10)
243 %r = tail call i16 @llvm.ctlz.i16(i16 %p, i1 false)
247 define signext i8 @func8sx(i8 signext %p) {
248 ; CHECK-LABEL: func8sx:
250 ; CHECK-NEXT: and %s0, %s0, (56)0
251 ; CHECK-NEXT: ldz %s0, %s0
252 ; CHECK-NEXT: lea %s0, -32(, %s0)
253 ; CHECK-NEXT: adds.w.sx %s0, -24, %s0
254 ; CHECK-NEXT: and %s0, %s0, (56)0
255 ; CHECK-NEXT: b.l.t (, %s10)
256 %r = tail call i8 @llvm.ctlz.i8(i8 %p, i1 false)
260 define zeroext i8 @func8zx(i8 zeroext %p) {
261 ; CHECK-LABEL: func8zx:
263 ; CHECK-NEXT: ldz %s0, %s0
264 ; CHECK-NEXT: lea %s0, -32(, %s0)
265 ; CHECK-NEXT: adds.w.sx %s0, -24, %s0
266 ; CHECK-NEXT: and %s0, %s0, (56)0
267 ; CHECK-NEXT: b.l.t (, %s10)
268 %r = tail call i8 @llvm.ctlz.i8(i8 %p, i1 false)