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: # kill: def $edi killed $edi def $rdi
44 ; X64-NEXT: movl %edi, %eax
45 ; X64-NEXT: shll $8, %eax
46 ; X64-NEXT: shrl $8, %edi
47 ; X64-NEXT: andl $65280, %edi # imm = 0xFF00
48 ; X64-NEXT: andl $16711680, %eax # imm = 0xFF0000
49 ; X64-NEXT: addl %edi, %eax
53 %mask_r8 = and i32 %r8, 4278255360
54 %mask_l8 = and i32 %l8, 16711935
55 %tmp = or i32 %mask_r8, %mask_l8
59 define i32 @extra_maskop_uses2(i32 %a) {
60 ; X86-LABEL: extra_maskop_uses2:
62 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
63 ; X86-NEXT: movl %ecx, %edx
64 ; X86-NEXT: shll $8, %edx
65 ; X86-NEXT: shrl $8, %ecx
66 ; X86-NEXT: andl $-16711936, %edx # imm = 0xFF00FF00
67 ; X86-NEXT: andl $16711935, %ecx # imm = 0xFF00FF
68 ; X86-NEXT: leal (%ecx,%edx), %eax
69 ; X86-NEXT: imull %edx, %eax
70 ; X86-NEXT: imull %ecx, %eax
73 ; X64-LABEL: extra_maskop_uses2:
75 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
76 ; X64-NEXT: movl %edi, %ecx
77 ; X64-NEXT: shll $8, %ecx
78 ; X64-NEXT: shrl $8, %edi
79 ; X64-NEXT: andl $-16711936, %ecx # imm = 0xFF00FF00
80 ; X64-NEXT: andl $16711935, %edi # imm = 0xFF00FF
81 ; X64-NEXT: leal (%rdi,%rcx), %eax
82 ; X64-NEXT: imull %ecx, %eax
83 ; X64-NEXT: imull %edi, %eax
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: # kill: def $edi killed $edi def $rdi
132 ; X64-NEXT: movl %edi, %eax
133 ; X64-NEXT: shll $9, %eax
134 ; X64-NEXT: shrl $8, %edi
135 ; X64-NEXT: andl $-16712192, %eax # imm = 0xFF00FE00
136 ; X64-NEXT: andl $16711935, %edi # imm = 0xFF00FF
137 ; X64-NEXT: addl %edi, %eax
141 %mask_l8 = and i32 %l8, 4278255360
142 %mask_r8 = and i32 %r8, 16711935
143 %tmp = or i32 %mask_l8, %mask_r8
147 define i32 @different_constant(i32 %a) {
148 ; X86-LABEL: different_constant:
150 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
151 ; X86-NEXT: shrl $8, %eax
152 ; X86-NEXT: andl $16711935, %eax # imm = 0xFF00FF
155 ; X64-LABEL: different_constant:
157 ; X64-NEXT: movl %edi, %eax
158 ; X64-NEXT: shrl $8, %eax
159 ; X64-NEXT: andl $16711935, %eax # imm = 0xFF00FF
163 %mask_l8 = and i32 %l8, 42
164 %mask_r8 = and i32 %r8, 16711935
165 %tmp = or i32 %mask_l8, %mask_r8
169 define i32 @different_op(i32 %a) {
170 ; X86-LABEL: different_op:
172 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
173 ; X86-NEXT: movl %eax, %ecx
174 ; X86-NEXT: shll $8, %ecx
175 ; X86-NEXT: shrl $8, %eax
176 ; X86-NEXT: addl $16711936, %ecx # imm = 0xFF0100
177 ; X86-NEXT: andl $16711935, %eax # imm = 0xFF00FF
178 ; X86-NEXT: orl %ecx, %eax
181 ; X64-LABEL: different_op:
183 ; X64-NEXT: movl %edi, %eax
184 ; X64-NEXT: shll $8, %eax
185 ; X64-NEXT: shrl $8, %edi
186 ; X64-NEXT: addl $16711936, %eax # imm = 0xFF0100
187 ; X64-NEXT: andl $16711935, %edi # imm = 0xFF00FF
188 ; X64-NEXT: orl %edi, %eax
192 %mask_l8 = sub i32 %l8, 4278255360
193 %mask_r8 = and i32 %r8, 16711935
194 %tmp = or i32 %mask_l8, %mask_r8
198 define i32 @different_vars(i32 %a, i32 %b) {
199 ; X86-LABEL: different_vars:
201 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
202 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
203 ; X86-NEXT: shll $8, %ecx
204 ; X86-NEXT: shrl $8, %eax
205 ; X86-NEXT: andl $-16711936, %ecx # imm = 0xFF00FF00
206 ; X86-NEXT: andl $16711935, %eax # imm = 0xFF00FF
207 ; X86-NEXT: orl %ecx, %eax
210 ; X64-LABEL: different_vars:
212 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
213 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
214 ; X64-NEXT: shll $8, %edi
215 ; X64-NEXT: shrl $8, %esi
216 ; X64-NEXT: andl $-16711936, %edi # imm = 0xFF00FF00
217 ; X64-NEXT: andl $16711935, %esi # imm = 0xFF00FF
218 ; X64-NEXT: leal (%rsi,%rdi), %eax
222 %mask_l8 = and i32 %l8, 4278255360
223 %mask_r8 = and i32 %r8, 16711935
224 %tmp = or i32 %mask_l8, %mask_r8
228 ; 0xff000000 = 4278190080
229 ; 0x00ff0000 = 16711680
232 define i32 @f2(i32 %a) {
235 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
236 ; X86-NEXT: bswapl %eax
237 ; X86-NEXT: roll $16, %eax
242 ; X64-NEXT: movl %edi, %eax
243 ; X64-NEXT: bswapl %eax
244 ; X64-NEXT: roll $16, %eax
248 %masklo_l8 = and i32 %l8, 65280
249 %maskhi_l8 = and i32 %l8, 4278190080
250 %masklo_r8 = and i32 %r8, 255
251 %maskhi_r8 = and i32 %r8, 16711680
252 %tmp1 = or i32 %masklo_l8, %masklo_r8
253 %tmp2 = or i32 %maskhi_l8, %maskhi_r8
254 %tmp = or i32 %tmp1, %tmp2