1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-- | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-- | FileCheck %s --check-prefix=X64
5 ; 0xff00ff00 = 4278255360
6 ; 0x00ff00ff = 16711935
7 define i32 @rev16(i32 %a) {
10 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
11 ; X86-NEXT: bswapl %eax
12 ; X86-NEXT: rorl $16, %eax
17 ; X64-NEXT: movl %edi, %eax
18 ; X64-NEXT: bswapl %eax
19 ; X64-NEXT: rorl $16, %eax
23 %mask_l8 = and i32 %l8, 4278255360
24 %mask_r8 = and i32 %r8, 16711935
25 %tmp = or i32 %mask_l8, %mask_r8
29 define i32 @not_rev16(i32 %a) {
30 ; X86-LABEL: not_rev16:
32 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
33 ; X86-NEXT: movl %ecx, %eax
34 ; X86-NEXT: shll $8, %eax
35 ; X86-NEXT: shrl $8, %ecx
36 ; X86-NEXT: andl $65280, %ecx # imm = 0xFF00
37 ; X86-NEXT: andl $16711680, %eax # imm = 0xFF0000
38 ; X86-NEXT: orl %ecx, %eax
41 ; X64-LABEL: not_rev16:
43 ; X64-NEXT: movl %edi, %eax
44 ; X64-NEXT: shll $8, %eax
45 ; X64-NEXT: shrl $8, %edi
46 ; X64-NEXT: andl $65280, %edi # imm = 0xFF00
47 ; X64-NEXT: andl $16711680, %eax # imm = 0xFF0000
48 ; X64-NEXT: orl %edi, %eax
52 %mask_r8 = and i32 %r8, 4278255360
53 %mask_l8 = and i32 %l8, 16711935
54 %tmp = or i32 %mask_r8, %mask_l8
58 define i32 @extra_maskop_uses2(i32 %a) {
59 ; X86-LABEL: extra_maskop_uses2:
61 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
62 ; X86-NEXT: movl %eax, %ecx
63 ; X86-NEXT: shll $8, %ecx
64 ; X86-NEXT: shrl $8, %eax
65 ; X86-NEXT: andl $-16711936, %ecx # imm = 0xFF00FF00
66 ; X86-NEXT: andl $16711935, %eax # imm = 0xFF00FF
67 ; X86-NEXT: leal (%eax,%ecx), %edx
68 ; X86-NEXT: imull %ecx, %eax
69 ; X86-NEXT: imull %edx, %eax
72 ; X64-LABEL: extra_maskop_uses2:
74 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
75 ; X64-NEXT: movl %edi, %eax
76 ; X64-NEXT: shll $8, %eax
77 ; X64-NEXT: shrl $8, %edi
78 ; X64-NEXT: andl $-16711936, %eax # imm = 0xFF00FF00
79 ; X64-NEXT: andl $16711935, %edi # imm = 0xFF00FF
80 ; X64-NEXT: leal (%rdi,%rax), %ecx
81 ; X64-NEXT: imull %edi, %eax
82 ; X64-NEXT: imull %ecx, %eax
83 ; X64-NEXT: # kill: def $eax killed $eax killed $rax
87 %mask_l8 = and i32 %l8, 4278255360
88 %mask_r8 = and i32 %r8, 16711935
89 %or = or i32 %mask_r8, %mask_l8
90 %mul = mul i32 %mask_r8, %mask_l8 ; another use of the mask ops
91 %r = mul i32 %mul, %or ; and use that result
95 define i32 @bswap_ror_commuted(i32 %a) {
96 ; X86-LABEL: bswap_ror_commuted:
98 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
99 ; X86-NEXT: bswapl %eax
100 ; X86-NEXT: rorl $16, %eax
103 ; X64-LABEL: bswap_ror_commuted:
105 ; X64-NEXT: movl %edi, %eax
106 ; X64-NEXT: bswapl %eax
107 ; X64-NEXT: rorl $16, %eax
111 %mask_l8 = and i32 %l8, 4278255360
112 %mask_r8 = and i32 %r8, 16711935
113 %tmp = or i32 %mask_r8, %mask_l8
117 define i32 @different_shift_amount(i32 %a) {
118 ; X86-LABEL: different_shift_amount:
120 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
121 ; X86-NEXT: movl %eax, %ecx
122 ; X86-NEXT: shll $9, %ecx
123 ; X86-NEXT: shrl $8, %eax
124 ; X86-NEXT: andl $-16712192, %ecx # imm = 0xFF00FE00
125 ; X86-NEXT: andl $16711935, %eax # imm = 0xFF00FF
126 ; X86-NEXT: orl %ecx, %eax
129 ; X64-LABEL: different_shift_amount:
131 ; X64-NEXT: movl %edi, %eax
132 ; X64-NEXT: shll $9, %eax
133 ; X64-NEXT: shrl $8, %edi
134 ; X64-NEXT: andl $-16712192, %eax # imm = 0xFF00FE00
135 ; X64-NEXT: andl $16711935, %edi # imm = 0xFF00FF
136 ; X64-NEXT: orl %edi, %eax
140 %mask_l8 = and i32 %l8, 4278255360
141 %mask_r8 = and i32 %r8, 16711935
142 %tmp = or i32 %mask_l8, %mask_r8
146 define i32 @different_constant(i32 %a) {
147 ; X86-LABEL: different_constant:
149 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
150 ; X86-NEXT: shrl $8, %eax
151 ; X86-NEXT: andl $16711935, %eax # imm = 0xFF00FF
154 ; X64-LABEL: different_constant:
156 ; X64-NEXT: movl %edi, %eax
157 ; X64-NEXT: shrl $8, %eax
158 ; X64-NEXT: andl $16711935, %eax # imm = 0xFF00FF
162 %mask_l8 = and i32 %l8, 42
163 %mask_r8 = and i32 %r8, 16711935
164 %tmp = or i32 %mask_l8, %mask_r8
168 define i32 @different_op(i32 %a) {
169 ; X86-LABEL: different_op:
171 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
172 ; X86-NEXT: movl %eax, %ecx
173 ; X86-NEXT: shll $8, %ecx
174 ; X86-NEXT: shrl $8, %eax
175 ; X86-NEXT: addl $16711936, %ecx # imm = 0xFF0100
176 ; X86-NEXT: andl $16711935, %eax # imm = 0xFF00FF
177 ; X86-NEXT: orl %ecx, %eax
180 ; X64-LABEL: different_op:
182 ; X64-NEXT: movl %edi, %eax
183 ; X64-NEXT: shll $8, %eax
184 ; X64-NEXT: shrl $8, %edi
185 ; X64-NEXT: addl $16711936, %eax # imm = 0xFF0100
186 ; X64-NEXT: andl $16711935, %edi # imm = 0xFF00FF
187 ; X64-NEXT: orl %edi, %eax
191 %mask_l8 = sub i32 %l8, 4278255360
192 %mask_r8 = and i32 %r8, 16711935
193 %tmp = or i32 %mask_l8, %mask_r8
197 define i32 @different_vars(i32 %a, i32 %b) {
198 ; X86-LABEL: different_vars:
200 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
201 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
202 ; X86-NEXT: shll $8, %ecx
203 ; X86-NEXT: shrl $8, %eax
204 ; X86-NEXT: andl $-16711936, %ecx # imm = 0xFF00FF00
205 ; X86-NEXT: andl $16711935, %eax # imm = 0xFF00FF
206 ; X86-NEXT: orl %ecx, %eax
209 ; X64-LABEL: different_vars:
211 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
212 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
213 ; X64-NEXT: shll $8, %edi
214 ; X64-NEXT: shrl $8, %esi
215 ; X64-NEXT: andl $-16711936, %edi # imm = 0xFF00FF00
216 ; X64-NEXT: andl $16711935, %esi # imm = 0xFF00FF
217 ; X64-NEXT: leal (%rsi,%rdi), %eax
221 %mask_l8 = and i32 %l8, 4278255360
222 %mask_r8 = and i32 %r8, 16711935
223 %tmp = or i32 %mask_l8, %mask_r8
227 ; 0xff000000 = 4278190080
228 ; 0x00ff0000 = 16711680
231 define i32 @f2(i32 %a) {
234 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
235 ; X86-NEXT: bswapl %eax
236 ; X86-NEXT: roll $16, %eax
241 ; X64-NEXT: movl %edi, %eax
242 ; X64-NEXT: bswapl %eax
243 ; X64-NEXT: roll $16, %eax
247 %masklo_l8 = and i32 %l8, 65280
248 %maskhi_l8 = and i32 %l8, 4278190080
249 %masklo_r8 = and i32 %r8, 255
250 %maskhi_r8 = and i32 %r8, 16711680
251 %tmp1 = or i32 %masklo_l8, %masklo_r8
252 %tmp2 = or i32 %maskhi_l8, %maskhi_r8
253 %tmp = or i32 %tmp1, %tmp2