cttz.ll
4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
; RUN: llc < %s -mtriple=ve-unknown-unknown | FileCheck %s
declare i128 @llvm.cttz.i128(i128, i1)
declare i64 @llvm.cttz.i64(i64, i1)
declare i32 @llvm.cttz.i32(i32, i1)
declare i16 @llvm.cttz.i16(i16, i1)
declare i8 @llvm.cttz.i8(i8, i1)
define i128 @func128(i128 %p) {
; CHECK-LABEL: func128:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: or %s2, 0, (0)1
; CHECK-NEXT: cmps.l %s3, %s0, %s2
; CHECK-NEXT: lea %s4, -1(, %s0)
; CHECK-NEXT: nnd %s0, %s0, %s4
; CHECK-NEXT: pcnt %s4, %s0
; CHECK-NEXT: lea %s0, -1(, %s1)
; CHECK-NEXT: nnd %s0, %s1, %s0
; CHECK-NEXT: pcnt %s0, %s0
; CHECK-NEXT: lea %s0, 64(, %s0)
; CHECK-NEXT: cmov.l.ne %s0, %s4, %s3
; CHECK-NEXT: or %s1, 0, %s2
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i128 @llvm.cttz.i128(i128 %p, i1 true)
ret i128 %r
}
define i64 @func64(i64 %p) {
; CHECK-LABEL: func64:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: lea %s1, -1(, %s0)
; CHECK-NEXT: nnd %s0, %s0, %s1
; CHECK-NEXT: pcnt %s0, %s0
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i64 @llvm.cttz.i64(i64 %p, i1 true)
ret i64 %r
}
define signext i32 @func32s(i32 signext %p) {
; CHECK-LABEL: func32s:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: adds.w.sx %s1, -1, %s0
; CHECK-NEXT: nnd %s0, %s0, %s1
; CHECK-NEXT: and %s0, %s0, (32)0
; CHECK-NEXT: pcnt %s0, %s0
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i32 @llvm.cttz.i32(i32 %p, i1 true)
ret i32 %r
}
define zeroext i32 @func32z(i32 zeroext %p) {
; CHECK-LABEL: func32z:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: adds.w.sx %s1, -1, %s0
; CHECK-NEXT: nnd %s0, %s0, %s1
; CHECK-NEXT: and %s0, %s0, (32)0
; CHECK-NEXT: pcnt %s0, %s0
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i32 @llvm.cttz.i32(i32 %p, i1 true)
ret i32 %r
}
define signext i16 @func16s(i16 signext %p) {
; CHECK-LABEL: func16s:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: adds.w.sx %s1, -1, %s0
; CHECK-NEXT: nnd %s0, %s0, %s1
; CHECK-NEXT: and %s0, %s0, (32)0
; CHECK-NEXT: pcnt %s0, %s0
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i16 @llvm.cttz.i16(i16 %p, i1 true)
ret i16 %r
}
define zeroext i16 @func16z(i16 zeroext %p) {
; CHECK-LABEL: func16z:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: adds.w.sx %s1, -1, %s0
; CHECK-NEXT: nnd %s0, %s0, %s1
; CHECK-NEXT: and %s0, %s0, (32)0
; CHECK-NEXT: pcnt %s0, %s0
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i16 @llvm.cttz.i16(i16 %p, i1 true)
ret i16 %r
}
define signext i8 @func8s(i8 signext %p) {
; CHECK-LABEL: func8s:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: adds.w.sx %s1, -1, %s0
; CHECK-NEXT: nnd %s0, %s0, %s1
; CHECK-NEXT: and %s0, %s0, (32)0
; CHECK-NEXT: pcnt %s0, %s0
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i8 @llvm.cttz.i8(i8 %p, i1 true)
ret i8 %r
}
define zeroext i8 @func8z(i8 zeroext %p) {
; CHECK-LABEL: func8z:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: adds.w.sx %s1, -1, %s0
; CHECK-NEXT: nnd %s0, %s0, %s1
; CHECK-NEXT: and %s0, %s0, (32)0
; CHECK-NEXT: pcnt %s0, %s0
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i8 @llvm.cttz.i8(i8 %p, i1 true)
ret i8 %r
}
define i128 @func128i() {
; CHECK-LABEL: func128i:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: or %s0, 8, (0)1
; CHECK-NEXT: or %s1, 0, (0)1
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i128 @llvm.cttz.i128(i128 65280, i1 true)
ret i128 %r
}
define i64 @func64i() {
; CHECK-LABEL: func64i:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: or %s0, 8, (0)1
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i64 @llvm.cttz.i64(i64 65280, i1 true)
ret i64 %r
}
define signext i32 @func32is() {
; CHECK-LABEL: func32is:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: or %s0, 8, (0)1
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i32 @llvm.cttz.i32(i32 65280, i1 true)
ret i32 %r
}
define zeroext i32 @func32iz() {
; CHECK-LABEL: func32iz:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: or %s0, 8, (0)1
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i32 @llvm.cttz.i32(i32 65280, i1 true)
ret i32 %r
}
define signext i16 @func16is() {
; CHECK-LABEL: func16is:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: or %s0, 8, (0)1
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i16 @llvm.cttz.i16(i16 65280, i1 true)
ret i16 %r
}
define zeroext i16 @func16iz() {
; CHECK-LABEL: func16iz:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: or %s0, 8, (0)1
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i16 @llvm.cttz.i16(i16 65280, i1 true)
ret i16 %r
}
define signext i8 @func8is() {
; CHECK-LABEL: func8is:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: or %s0, 4, (0)1
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i8 @llvm.cttz.i8(i8 240, i1 true)
ret i8 %r
}
define zeroext i8 @func8iz() {
; CHECK-LABEL: func8iz:
; CHECK: .LBB{{[0-9]+}}_2:
; CHECK-NEXT: or %s0, 4, (0)1
; CHECK-NEXT: or %s11, 0, %s9
%r = tail call i8 @llvm.cttz.i8(i8 240, i1 true)
ret i8 %r
}