1 ; RUN: llc < %s -march=x86-64 -mattr=+bmi,+bmi2 | FileCheck %s
3 declare i8 @llvm.cttz.i8(i8, i1) nounwind readnone
4 declare i16 @llvm.cttz.i16(i16, i1) nounwind readnone
5 declare i32 @llvm.cttz.i32(i32, i1) nounwind readnone
6 declare i64 @llvm.cttz.i64(i64, i1) nounwind readnone
8 define i8 @t1(i8 %x) nounwind {
9 %tmp = tail call i8 @llvm.cttz.i8( i8 %x, i1 false )
15 define i16 @t2(i16 %x) nounwind {
16 %tmp = tail call i16 @llvm.cttz.i16( i16 %x, i1 false )
22 define i32 @t3(i32 %x) nounwind {
23 %tmp = tail call i32 @llvm.cttz.i32( i32 %x, i1 false )
29 define i32 @tzcnt32_load(i32* %x) nounwind {
31 %tmp = tail call i32 @llvm.cttz.i32(i32 %x1, i1 false )
33 ; CHECK: tzcnt32_load:
34 ; CHECK: tzcntl ({{.*}})
37 define i64 @t4(i64 %x) nounwind {
38 %tmp = tail call i64 @llvm.cttz.i64( i64 %x, i1 false )
44 define i8 @t5(i8 %x) nounwind {
45 %tmp = tail call i8 @llvm.cttz.i8( i8 %x, i1 true )
51 define i16 @t6(i16 %x) nounwind {
52 %tmp = tail call i16 @llvm.cttz.i16( i16 %x, i1 true )
58 define i32 @t7(i32 %x) nounwind {
59 %tmp = tail call i32 @llvm.cttz.i32( i32 %x, i1 true )
65 define i64 @t8(i64 %x) nounwind {
66 %tmp = tail call i64 @llvm.cttz.i64( i64 %x, i1 true )
72 define i32 @andn32(i32 %x, i32 %y) nounwind readnone {
73 %tmp1 = xor i32 %x, -1
74 %tmp2 = and i32 %y, %tmp1
80 define i32 @andn32_load(i32 %x, i32* %y) nounwind readnone {
82 %tmp1 = xor i32 %x, -1
83 %tmp2 = and i32 %y1, %tmp1
86 ; CHECK: andnl ({{.*}})
89 define i64 @andn64(i64 %x, i64 %y) nounwind readnone {
90 %tmp1 = xor i64 %x, -1
91 %tmp2 = and i64 %tmp1, %y
97 define i32 @bextr32(i32 %x, i32 %y) nounwind readnone {
98 %tmp = tail call i32 @llvm.x86.bmi.bextr.32(i32 %x, i32 %y)
104 define i32 @bextr32_load(i32* %x, i32 %y) nounwind readnone {
106 %tmp = tail call i32 @llvm.x86.bmi.bextr.32(i32 %x1, i32 %y)
108 ; CHECK: bextr32_load:
109 ; CHECK: bextrl {{.*}}, ({{.*}}), {{.*}}
112 declare i32 @llvm.x86.bmi.bextr.32(i32, i32) nounwind readnone
114 define i64 @bextr64(i64 %x, i64 %y) nounwind readnone {
115 %tmp = tail call i64 @llvm.x86.bmi.bextr.64(i64 %x, i64 %y)
121 declare i64 @llvm.x86.bmi.bextr.64(i64, i64) nounwind readnone
123 define i32 @bzhi32(i32 %x, i32 %y) nounwind readnone {
124 %tmp = tail call i32 @llvm.x86.bmi.bzhi.32(i32 %x, i32 %y)
130 define i32 @bzhi32_load(i32* %x, i32 %y) nounwind readnone {
132 %tmp = tail call i32 @llvm.x86.bmi.bzhi.32(i32 %x1, i32 %y)
134 ; CHECK: bzhi32_load:
135 ; CHECK: bzhil {{.*}}, ({{.*}}), {{.*}}
138 declare i32 @llvm.x86.bmi.bzhi.32(i32, i32) nounwind readnone
140 define i64 @bzhi64(i64 %x, i64 %y) nounwind readnone {
141 %tmp = tail call i64 @llvm.x86.bmi.bzhi.64(i64 %x, i64 %y)
147 declare i64 @llvm.x86.bmi.bzhi.64(i64, i64) nounwind readnone
149 define i32 @blsi32(i32 %x) nounwind readnone {
151 %tmp2 = and i32 %x, %tmp
157 define i32 @blsi32_load(i32* %x) nounwind readnone {
159 %tmp = sub i32 0, %x1
160 %tmp2 = and i32 %x1, %tmp
162 ; CHECK: blsi32_load:
163 ; CHECK: blsil ({{.*}})
166 define i64 @blsi64(i64 %x) nounwind readnone {
168 %tmp2 = and i64 %tmp, %x
174 define i32 @blsmsk32(i32 %x) nounwind readnone {
176 %tmp2 = xor i32 %x, %tmp
182 define i32 @blsmsk32_load(i32* %x) nounwind readnone {
184 %tmp = sub i32 %x1, 1
185 %tmp2 = xor i32 %x1, %tmp
187 ; CHECK: blsmsk32_load:
188 ; CHECK: blsmskl ({{.*}})
191 define i64 @blsmsk64(i64 %x) nounwind readnone {
193 %tmp2 = xor i64 %tmp, %x
199 define i32 @blsr32(i32 %x) nounwind readnone {
201 %tmp2 = and i32 %x, %tmp
207 define i32 @blsr32_load(i32* %x) nounwind readnone {
209 %tmp = sub i32 %x1, 1
210 %tmp2 = and i32 %x1, %tmp
212 ; CHECK: blsr32_load:
213 ; CHECK: blsrl ({{.*}})
216 define i64 @blsr64(i64 %x) nounwind readnone {
218 %tmp2 = and i64 %tmp, %x
224 define i32 @pdep32(i32 %x, i32 %y) nounwind readnone {
225 %tmp = tail call i32 @llvm.x86.bmi.pdep.32(i32 %x, i32 %y)
231 define i32 @pdep32_load(i32 %x, i32* %y) nounwind readnone {
233 %tmp = tail call i32 @llvm.x86.bmi.pdep.32(i32 %x, i32 %y1)
235 ; CHECK: pdep32_load:
236 ; CHECK: pdepl ({{.*}})
239 declare i32 @llvm.x86.bmi.pdep.32(i32, i32) nounwind readnone
241 define i64 @pdep64(i64 %x, i64 %y) nounwind readnone {
242 %tmp = tail call i64 @llvm.x86.bmi.pdep.64(i64 %x, i64 %y)
248 declare i64 @llvm.x86.bmi.pdep.64(i64, i64) nounwind readnone
250 define i32 @pext32(i32 %x, i32 %y) nounwind readnone {
251 %tmp = tail call i32 @llvm.x86.bmi.pext.32(i32 %x, i32 %y)
257 define i32 @pext32_load(i32 %x, i32* %y) nounwind readnone {
259 %tmp = tail call i32 @llvm.x86.bmi.pext.32(i32 %x, i32 %y1)
261 ; CHECK: pext32_load:
262 ; CHECK: pextl ({{.*}})
265 declare i32 @llvm.x86.bmi.pext.32(i32, i32) nounwind readnone
267 define i64 @pext64(i64 %x, i64 %y) nounwind readnone {
268 %tmp = tail call i64 @llvm.x86.bmi.pext.64(i64 %x, i64 %y)
274 declare i64 @llvm.x86.bmi.pext.64(i64, i64) nounwind readnone