1 ; RUN: llc < %s -mtriple=ve-unknown-unknown | FileCheck %s
3 declare i128 @llvm.cttz.i128(i128, i1)
4 declare i64 @llvm.cttz.i64(i64, i1)
5 declare i32 @llvm.cttz.i32(i32, i1)
6 declare i16 @llvm.cttz.i16(i16, i1)
7 declare i8 @llvm.cttz.i8(i8, i1)
9 define i128 @func128(i128 %p) {
10 ; CHECK-LABEL: func128:
12 ; CHECK-NEXT: lea %s2, -1(, %s0)
13 ; CHECK-NEXT: nnd %s2, %s0, %s2
14 ; CHECK-NEXT: pcnt %s3, %s2
15 ; CHECK-NEXT: lea %s2, -1(, %s1)
16 ; CHECK-NEXT: nnd %s1, %s1, %s2
17 ; CHECK-NEXT: pcnt %s1, %s1
18 ; CHECK-NEXT: lea %s2, 64(, %s1)
19 ; CHECK-NEXT: cmov.l.ne %s2, %s3, %s0
20 ; CHECK-NEXT: or %s1, 0, (0)1
21 ; CHECK-NEXT: or %s0, 0, %s2
22 ; CHECK-NEXT: b.l.t (, %s10)
23 %r = tail call i128 @llvm.cttz.i128(i128 %p, i1 true)
27 define i64 @func64(i64 %p) {
28 ; CHECK-LABEL: func64:
30 ; CHECK-NEXT: lea %s1, -1(, %s0)
31 ; CHECK-NEXT: nnd %s0, %s0, %s1
32 ; CHECK-NEXT: pcnt %s0, %s0
33 ; CHECK-NEXT: b.l.t (, %s10)
34 %r = tail call i64 @llvm.cttz.i64(i64 %p, i1 true)
38 define signext i32 @func32s(i32 signext %p) {
39 ; CHECK-LABEL: func32s:
41 ; CHECK-NEXT: adds.w.sx %s1, -1, %s0
42 ; CHECK-NEXT: nnd %s0, %s0, %s1
43 ; CHECK-NEXT: and %s0, %s0, (32)0
44 ; CHECK-NEXT: pcnt %s0, %s0
45 ; CHECK-NEXT: b.l.t (, %s10)
46 %r = tail call i32 @llvm.cttz.i32(i32 %p, i1 true)
50 define zeroext i32 @func32z(i32 zeroext %p) {
51 ; CHECK-LABEL: func32z:
53 ; CHECK-NEXT: adds.w.sx %s1, -1, %s0
54 ; CHECK-NEXT: nnd %s0, %s0, %s1
55 ; CHECK-NEXT: and %s0, %s0, (32)0
56 ; CHECK-NEXT: pcnt %s0, %s0
57 ; CHECK-NEXT: b.l.t (, %s10)
58 %r = tail call i32 @llvm.cttz.i32(i32 %p, i1 true)
62 define signext i16 @func16s(i16 signext %p) {
63 ; CHECK-LABEL: func16s:
65 ; CHECK-NEXT: adds.w.sx %s1, -1, %s0
66 ; CHECK-NEXT: nnd %s0, %s0, %s1
67 ; CHECK-NEXT: and %s0, %s0, (48)0
68 ; CHECK-NEXT: pcnt %s0, %s0
69 ; CHECK-NEXT: b.l.t (, %s10)
70 %r = tail call i16 @llvm.cttz.i16(i16 %p, i1 true)
74 define zeroext i16 @func16z(i16 zeroext %p) {
75 ; CHECK-LABEL: func16z:
77 ; CHECK-NEXT: adds.w.sx %s1, -1, %s0
78 ; CHECK-NEXT: nnd %s0, %s0, %s1
79 ; CHECK-NEXT: and %s0, %s0, (48)0
80 ; CHECK-NEXT: pcnt %s0, %s0
81 ; CHECK-NEXT: b.l.t (, %s10)
82 %r = tail call i16 @llvm.cttz.i16(i16 %p, i1 true)
86 define signext i8 @func8s(i8 signext %p) {
87 ; CHECK-LABEL: func8s:
89 ; CHECK-NEXT: adds.w.sx %s1, -1, %s0
90 ; CHECK-NEXT: nnd %s0, %s0, %s1
91 ; CHECK-NEXT: and %s0, %s0, (56)0
92 ; CHECK-NEXT: pcnt %s0, %s0
93 ; CHECK-NEXT: b.l.t (, %s10)
94 %r = tail call i8 @llvm.cttz.i8(i8 %p, i1 true)
98 define zeroext i8 @func8z(i8 zeroext %p) {
99 ; CHECK-LABEL: func8z:
101 ; CHECK-NEXT: adds.w.sx %s1, -1, %s0
102 ; CHECK-NEXT: nnd %s0, %s0, %s1
103 ; CHECK-NEXT: and %s0, %s0, (56)0
104 ; CHECK-NEXT: pcnt %s0, %s0
105 ; CHECK-NEXT: b.l.t (, %s10)
106 %r = tail call i8 @llvm.cttz.i8(i8 %p, i1 true)
110 define i128 @func128i() {
111 ; CHECK-LABEL: func128i:
113 ; CHECK-NEXT: or %s0, 8, (0)1
114 ; CHECK-NEXT: or %s1, 0, (0)1
115 ; CHECK-NEXT: b.l.t (, %s10)
116 %r = tail call i128 @llvm.cttz.i128(i128 65280, i1 true)
120 define i64 @func64i() {
121 ; CHECK-LABEL: func64i:
123 ; CHECK-NEXT: or %s0, 8, (0)1
124 ; CHECK-NEXT: b.l.t (, %s10)
125 %r = tail call i64 @llvm.cttz.i64(i64 65280, i1 true)
129 define signext i32 @func32is() {
130 ; CHECK-LABEL: func32is:
132 ; CHECK-NEXT: or %s0, 8, (0)1
133 ; CHECK-NEXT: b.l.t (, %s10)
134 %r = tail call i32 @llvm.cttz.i32(i32 65280, i1 true)
138 define zeroext i32 @func32iz() {
139 ; CHECK-LABEL: func32iz:
141 ; CHECK-NEXT: or %s0, 8, (0)1
142 ; CHECK-NEXT: b.l.t (, %s10)
143 %r = tail call i32 @llvm.cttz.i32(i32 65280, i1 true)
147 define signext i16 @func16is() {
148 ; CHECK-LABEL: func16is:
150 ; CHECK-NEXT: or %s0, 8, (0)1
151 ; CHECK-NEXT: b.l.t (, %s10)
152 %r = tail call i16 @llvm.cttz.i16(i16 65280, i1 true)
156 define zeroext i16 @func16iz() {
157 ; CHECK-LABEL: func16iz:
159 ; CHECK-NEXT: or %s0, 8, (0)1
160 ; CHECK-NEXT: b.l.t (, %s10)
161 %r = tail call i16 @llvm.cttz.i16(i16 65280, i1 true)
165 define signext i8 @func8is() {
166 ; CHECK-LABEL: func8is:
168 ; CHECK-NEXT: or %s0, 4, (0)1
169 ; CHECK-NEXT: b.l.t (, %s10)
170 %r = tail call i8 @llvm.cttz.i8(i8 240, i1 true)
174 define zeroext i8 @func8iz() {
175 ; CHECK-LABEL: func8iz:
177 ; CHECK-NEXT: or %s0, 4, (0)1
178 ; CHECK-NEXT: b.l.t (, %s10)
179 %r = tail call i8 @llvm.cttz.i8(i8 240, i1 true)