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