• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4
5; 0xff00ff00 = 4278255360
6; 0x00ff00ff = 16711935
7define i32 @rev16(i32 %a) {
8; X86-LABEL: rev16:
9; X86:       # %bb.0:
10; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
11; X86-NEXT:    bswapl %eax
12; X86-NEXT:    rorl $16, %eax
13; X86-NEXT:    retl
14;
15; X64-LABEL: rev16:
16; X64:       # %bb.0:
17; X64-NEXT:    movl %edi, %eax
18; X64-NEXT:    bswapl %eax
19; X64-NEXT:    rorl $16, %eax
20; X64-NEXT:    retq
21  %l8 = shl i32 %a, 8
22  %r8 = lshr i32 %a, 8
23  %mask_l8 = and i32 %l8, 4278255360
24  %mask_r8 = and i32 %r8, 16711935
25  %tmp = or i32 %mask_l8, %mask_r8
26  ret i32 %tmp
27}
28
29define i32 @not_rev16(i32 %a) {
30; X86-LABEL: not_rev16:
31; X86:       # %bb.0:
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
39; X86-NEXT:    retl
40;
41; X64-LABEL: not_rev16:
42; X64:       # %bb.0:
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
50; X64-NEXT:    retq
51  %l8 = shl i32 %a, 8
52  %r8 = lshr i32 %a, 8
53  %mask_r8 = and i32 %r8, 4278255360
54  %mask_l8 = and i32 %l8, 16711935
55  %tmp = or i32 %mask_r8, %mask_l8
56  ret i32 %tmp
57}
58
59define i32 @extra_maskop_uses2(i32 %a) {
60; X86-LABEL: extra_maskop_uses2:
61; X86:       # %bb.0:
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
71; X86-NEXT:    retl
72;
73; X64-LABEL: extra_maskop_uses2:
74; X64:       # %bb.0:
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
84; X64-NEXT:    retq
85  %l8 = shl i32 %a, 8
86  %r8 = lshr i32 %a, 8
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
92  ret i32 %r
93}
94
95define i32 @bswap_ror_commuted(i32 %a) {
96; X86-LABEL: bswap_ror_commuted:
97; X86:       # %bb.0:
98; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
99; X86-NEXT:    bswapl %eax
100; X86-NEXT:    rorl $16, %eax
101; X86-NEXT:    retl
102;
103; X64-LABEL: bswap_ror_commuted:
104; X64:       # %bb.0:
105; X64-NEXT:    movl %edi, %eax
106; X64-NEXT:    bswapl %eax
107; X64-NEXT:    rorl $16, %eax
108; X64-NEXT:    retq
109  %l8 = shl i32 %a, 8
110  %r8 = lshr i32 %a, 8
111  %mask_l8 = and i32 %l8, 4278255360
112  %mask_r8 = and i32 %r8, 16711935
113  %tmp = or i32 %mask_r8, %mask_l8
114  ret i32 %tmp
115}
116
117define i32 @different_shift_amount(i32 %a) {
118; X86-LABEL: different_shift_amount:
119; X86:       # %bb.0:
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
127; X86-NEXT:    retl
128;
129; X64-LABEL: different_shift_amount:
130; X64:       # %bb.0:
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
138; X64-NEXT:    retq
139  %l8 = shl i32 %a, 9
140  %r8 = lshr i32 %a, 8
141  %mask_l8 = and i32 %l8, 4278255360
142  %mask_r8 = and i32 %r8, 16711935
143  %tmp = or i32 %mask_l8, %mask_r8
144  ret i32 %tmp
145}
146
147define i32 @different_constant(i32 %a) {
148; X86-LABEL: different_constant:
149; X86:       # %bb.0:
150; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
151; X86-NEXT:    shrl $8, %eax
152; X86-NEXT:    andl $16711935, %eax # imm = 0xFF00FF
153; X86-NEXT:    retl
154;
155; X64-LABEL: different_constant:
156; X64:       # %bb.0:
157; X64-NEXT:    movl %edi, %eax
158; X64-NEXT:    shrl $8, %eax
159; X64-NEXT:    andl $16711935, %eax # imm = 0xFF00FF
160; X64-NEXT:    retq
161  %l8 = shl i32 %a, 8
162  %r8 = lshr i32 %a, 8
163  %mask_l8 = and i32 %l8, 42
164  %mask_r8 = and i32 %r8, 16711935
165  %tmp = or i32 %mask_l8, %mask_r8
166  ret i32 %tmp
167}
168
169define i32 @different_op(i32 %a) {
170; X86-LABEL: different_op:
171; X86:       # %bb.0:
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
179; X86-NEXT:    retl
180;
181; X64-LABEL: different_op:
182; X64:       # %bb.0:
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
189; X64-NEXT:    retq
190  %l8 = shl i32 %a, 8
191  %r8 = lshr i32 %a, 8
192  %mask_l8 = sub i32 %l8, 4278255360
193  %mask_r8 = and i32 %r8, 16711935
194  %tmp = or i32 %mask_l8, %mask_r8
195  ret i32 %tmp
196}
197
198define i32 @different_vars(i32 %a, i32 %b) {
199; X86-LABEL: different_vars:
200; X86:       # %bb.0:
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
208; X86-NEXT:    retl
209;
210; X64-LABEL: different_vars:
211; X64:       # %bb.0:
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
219; X64-NEXT:    retq
220  %l8 = shl i32 %a, 8
221  %r8 = lshr i32 %b, 8
222  %mask_l8 = and i32 %l8, 4278255360
223  %mask_r8 = and i32 %r8, 16711935
224  %tmp = or i32 %mask_l8, %mask_r8
225  ret i32 %tmp
226}
227
228; 0xff000000 = 4278190080
229; 0x00ff0000 = 16711680
230; 0x0000ff00 = 65280
231; 0x000000ff = 255
232define i32 @f2(i32 %a) {
233; X86-LABEL: f2:
234; X86:       # %bb.0:
235; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
236; X86-NEXT:    bswapl %eax
237; X86-NEXT:    roll $16, %eax
238; X86-NEXT:    retl
239;
240; X64-LABEL: f2:
241; X64:       # %bb.0:
242; X64-NEXT:    movl %edi, %eax
243; X64-NEXT:    bswapl %eax
244; X64-NEXT:    roll $16, %eax
245; X64-NEXT:    retq
246  %l8 = shl i32 %a, 8
247  %r8 = lshr i32 %a, 8
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
255  ret i32 %tmp
256}
257