Remove intrinsics for X86 BLSI, BLSMSK, and BLSR intrinsics and replace with custom...
[oota-llvm.git] / test / CodeGen / X86 / bmi.ll
1 ; RUN: llc < %s -march=x86-64 -mattr=+bmi,+bmi2 | FileCheck %s
2
3 define i32 @t1(i32 %x) nounwind  {
4        %tmp = tail call i32 @llvm.cttz.i32( i32 %x )
5        ret i32 %tmp
6 ; CHECK: t1:
7 ; CHECK: tzcntl
8 }
9
10 declare i32 @llvm.cttz.i32(i32) nounwind readnone
11
12 define i16 @t2(i16 %x) nounwind  {
13        %tmp = tail call i16 @llvm.cttz.i16( i16 %x )
14        ret i16 %tmp
15 ; CHECK: t2:
16 ; CHECK: tzcntw
17 }
18
19 declare i16 @llvm.cttz.i16(i16) nounwind readnone
20
21 define i64 @t3(i64 %x) nounwind  {
22        %tmp = tail call i64 @llvm.cttz.i64( i64 %x )
23        ret i64 %tmp
24 ; CHECK: t3:
25 ; CHECK: tzcntq
26 }
27
28 declare i64 @llvm.cttz.i64(i64) nounwind readnone
29
30 define i8 @t4(i8 %x) nounwind  {
31        %tmp = tail call i8 @llvm.cttz.i8( i8 %x )
32        ret i8 %tmp
33 ; CHECK: t4:
34 ; CHECK: tzcntw
35 }
36
37 declare i8 @llvm.cttz.i8(i8) nounwind readnone
38
39 define i32 @andn32(i32 %x, i32 %y) nounwind readnone {
40   %tmp1 = xor i32 %x, -1
41   %tmp2 = and i32 %y, %tmp1
42   ret i32 %tmp2
43 ; CHECK: andn32:
44 ; CHECK: andnl
45 }
46
47 define i64 @andn64(i64 %x, i64 %y) nounwind readnone {
48   %tmp1 = xor i64 %x, -1
49   %tmp2 = and i64 %tmp1, %y
50   ret i64 %tmp2
51 ; CHECK: andn64:
52 ; CHECK: andnq
53 }
54
55 define i32 @bextr32(i32 %x, i32 %y) nounwind readnone {
56   %tmp = tail call i32 @llvm.x86.bmi.bextr.32(i32 %x, i32 %y)
57   ret i32 %tmp
58 ; CHECK: bextr32:
59 ; CHECK: bextrl
60 }
61
62 declare i32 @llvm.x86.bmi.bextr.32(i32, i32) nounwind readnone
63
64 define i64 @bextr64(i64 %x, i64 %y) nounwind readnone {
65   %tmp = tail call i64 @llvm.x86.bmi.bextr.64(i64 %x, i64 %y)
66   ret i64 %tmp
67 ; CHECK: bextr64:
68 ; CHECK: bextrq
69 }
70
71 declare i64 @llvm.x86.bmi.bextr.64(i64, i64) nounwind readnone
72
73 define i32 @bzhi32(i32 %x, i32 %y) nounwind readnone {
74   %tmp = tail call i32 @llvm.x86.bmi.bzhi.32(i32 %x, i32 %y)
75   ret i32 %tmp
76 ; CHECK: bzhi32:
77 ; CHECK: bzhil
78 }
79
80 declare i32 @llvm.x86.bmi.bzhi.32(i32, i32) nounwind readnone
81
82 define i64 @bzhi64(i64 %x, i64 %y) nounwind readnone {
83   %tmp = tail call i64 @llvm.x86.bmi.bzhi.64(i64 %x, i64 %y)
84   ret i64 %tmp
85 ; CHECK: bzhi64:
86 ; CHECK: bzhiq
87 }
88
89 declare i64 @llvm.x86.bmi.bzhi.64(i64, i64) nounwind readnone
90
91 define i32 @blsi32(i32 %x) nounwind readnone {
92   %tmp = sub i32 0, %x
93   %tmp2 = and i32 %x, %tmp
94   ret i32 %tmp2
95 ; CHECK: blsi32:
96 ; CHECK: blsil
97 }
98
99 define i64 @blsi64(i64 %x) nounwind readnone {
100   %tmp = sub i64 0, %x
101   %tmp2 = and i64 %tmp, %x
102   ret i64 %tmp2
103 ; CHECK: blsi64:
104 ; CHECK: blsiq
105 }
106
107 define i32 @blsmsk32(i32 %x) nounwind readnone {
108   %tmp = sub i32 %x, 1
109   %tmp2 = xor i32 %x, %tmp
110   ret i32 %tmp2
111 ; CHECK: blsmsk32:
112 ; CHECK: blsmskl
113 }
114
115 define i64 @blsmsk64(i64 %x) nounwind readnone {
116   %tmp = sub i64 %x, 1
117   %tmp2 = xor i64 %tmp, %x
118   ret i64 %tmp2
119 ; CHECK: blsmsk64:
120 ; CHECK: blsmskq
121 }
122
123 define i32 @blsr32(i32 %x) nounwind readnone {
124   %tmp = sub i32 %x, 1
125   %tmp2 = and i32 %x, %tmp
126   ret i32 %tmp2
127 ; CHECK: blsr32:
128 ; CHECK: blsrl
129 }
130
131 define i64 @blsr64(i64 %x) nounwind readnone {
132   %tmp = sub i64 %x, 1
133   %tmp2 = and i64 %tmp, %x
134   ret i64 %tmp2
135 ; CHECK: blsr64:
136 ; CHECK: blsrq
137 }
138
139 define i32 @pdep32(i32 %x, i32 %y) nounwind readnone {
140   %tmp = tail call i32 @llvm.x86.bmi.pdep.32(i32 %x, i32 %y)
141   ret i32 %tmp
142 ; CHECK: pdep32:
143 ; CHECK: pdepl
144 }
145
146 declare i32 @llvm.x86.bmi.pdep.32(i32, i32) nounwind readnone
147
148 define i64 @pdep64(i64 %x, i64 %y) nounwind readnone {
149   %tmp = tail call i64 @llvm.x86.bmi.pdep.64(i64 %x, i64 %y)
150   ret i64 %tmp
151 ; CHECK: pdep64:
152 ; CHECK: pdepq
153 }
154
155 declare i64 @llvm.x86.bmi.pdep.64(i64, i64) nounwind readnone
156
157 define i32 @pext32(i32 %x, i32 %y) nounwind readnone {
158   %tmp = tail call i32 @llvm.x86.bmi.pext.32(i32 %x, i32 %y)
159   ret i32 %tmp
160 ; CHECK: pext32:
161 ; CHECK: pextl
162 }
163
164 declare i32 @llvm.x86.bmi.pext.32(i32, i32) nounwind readnone
165
166 define i64 @pext64(i64 %x, i64 %y) nounwind readnone {
167   %tmp = tail call i64 @llvm.x86.bmi.pext.64(i64 %x, i64 %y)
168   ret i64 %tmp
169 ; CHECK: pext64:
170 ; CHECK: pextq
171 }
172
173 declare i64 @llvm.x86.bmi.pext.64(i64, i64) nounwind readnone
174