1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=i686-unknown-linux-gnu < %s | FileCheck %s --check-prefix=X86
3 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s --check-prefix=X64
5 define i1 @t32_3_1(i32 %X) nounwind {
8 ; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB
9 ; X86-NEXT: addl $1431655765, %eax # imm = 0x55555555
10 ; X86-NEXT: cmpl $1431655765, %eax # imm = 0x55555555
16 ; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB
17 ; X64-NEXT: addl $1431655765, %eax # imm = 0x55555555
18 ; X64-NEXT: cmpl $1431655765, %eax # imm = 0x55555555
21 %urem = urem i32 %X, 3
22 %cmp = icmp eq i32 %urem, 1
26 define i1 @t32_3_2(i32 %X) nounwind {
29 ; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB
30 ; X86-NEXT: addl $-1431655766, %eax # imm = 0xAAAAAAAA
31 ; X86-NEXT: cmpl $1431655765, %eax # imm = 0x55555555
37 ; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB
38 ; X64-NEXT: addl $-1431655766, %eax # imm = 0xAAAAAAAA
39 ; X64-NEXT: cmpl $1431655765, %eax # imm = 0x55555555
42 %urem = urem i32 %X, 3
43 %cmp = icmp eq i32 %urem, 2
48 define i1 @t32_5_1(i32 %X) nounwind {
51 ; X86-NEXT: imull $-858993459, {{[0-9]+}}(%esp), %eax # imm = 0xCCCCCCCD
52 ; X86-NEXT: addl $858993459, %eax # imm = 0x33333333
53 ; X86-NEXT: cmpl $858993459, %eax # imm = 0x33333333
59 ; X64-NEXT: imull $-858993459, %edi, %eax # imm = 0xCCCCCCCD
60 ; X64-NEXT: addl $858993459, %eax # imm = 0x33333333
61 ; X64-NEXT: cmpl $858993459, %eax # imm = 0x33333333
64 %urem = urem i32 %X, 5
65 %cmp = icmp eq i32 %urem, 1
69 define i1 @t32_5_2(i32 %X) nounwind {
72 ; X86-NEXT: imull $-858993459, {{[0-9]+}}(%esp), %eax # imm = 0xCCCCCCCD
73 ; X86-NEXT: addl $1717986918, %eax # imm = 0x66666666
74 ; X86-NEXT: cmpl $858993459, %eax # imm = 0x33333333
80 ; X64-NEXT: imull $-858993459, %edi, %eax # imm = 0xCCCCCCCD
81 ; X64-NEXT: addl $1717986918, %eax # imm = 0x66666666
82 ; X64-NEXT: cmpl $858993459, %eax # imm = 0x33333333
85 %urem = urem i32 %X, 5
86 %cmp = icmp eq i32 %urem, 2
90 define i1 @t32_5_3(i32 %X) nounwind {
93 ; X86-NEXT: imull $-858993459, {{[0-9]+}}(%esp), %eax # imm = 0xCCCCCCCD
94 ; X86-NEXT: addl $-1717986919, %eax # imm = 0x99999999
95 ; X86-NEXT: cmpl $858993459, %eax # imm = 0x33333333
101 ; X64-NEXT: imull $-858993459, %edi, %eax # imm = 0xCCCCCCCD
102 ; X64-NEXT: addl $-1717986919, %eax # imm = 0x99999999
103 ; X64-NEXT: cmpl $858993459, %eax # imm = 0x33333333
106 %urem = urem i32 %X, 5
107 %cmp = icmp eq i32 %urem, 3
111 define i1 @t32_5_4(i32 %X) nounwind {
112 ; X86-LABEL: t32_5_4:
114 ; X86-NEXT: imull $-858993459, {{[0-9]+}}(%esp), %eax # imm = 0xCCCCCCCD
115 ; X86-NEXT: addl $-858993460, %eax # imm = 0xCCCCCCCC
116 ; X86-NEXT: cmpl $858993459, %eax # imm = 0x33333333
120 ; X64-LABEL: t32_5_4:
122 ; X64-NEXT: imull $-858993459, %edi, %eax # imm = 0xCCCCCCCD
123 ; X64-NEXT: addl $-858993460, %eax # imm = 0xCCCCCCCC
124 ; X64-NEXT: cmpl $858993459, %eax # imm = 0x33333333
127 %urem = urem i32 %X, 5
128 %cmp = icmp eq i32 %urem, 4
133 define i1 @t32_6_1(i32 %X) nounwind {
134 ; X86-LABEL: t32_6_1:
136 ; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB
137 ; X86-NEXT: addl $1431655765, %eax # imm = 0x55555555
138 ; X86-NEXT: rorl %eax
139 ; X86-NEXT: cmpl $715827883, %eax # imm = 0x2AAAAAAB
143 ; X64-LABEL: t32_6_1:
145 ; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB
146 ; X64-NEXT: addl $1431655765, %eax # imm = 0x55555555
147 ; X64-NEXT: rorl %eax
148 ; X64-NEXT: cmpl $715827883, %eax # imm = 0x2AAAAAAB
151 %urem = urem i32 %X, 6
152 %cmp = icmp eq i32 %urem, 1
156 define i1 @t32_6_2(i32 %X) nounwind {
157 ; X86-LABEL: t32_6_2:
159 ; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB
160 ; X86-NEXT: addl $-1431655766, %eax # imm = 0xAAAAAAAA
161 ; X86-NEXT: rorl %eax
162 ; X86-NEXT: cmpl $715827883, %eax # imm = 0x2AAAAAAB
166 ; X64-LABEL: t32_6_2:
168 ; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB
169 ; X64-NEXT: addl $-1431655766, %eax # imm = 0xAAAAAAAA
170 ; X64-NEXT: rorl %eax
171 ; X64-NEXT: cmpl $715827883, %eax # imm = 0x2AAAAAAB
174 %urem = urem i32 %X, 6
175 %cmp = icmp eq i32 %urem, 2
179 define i1 @t32_6_3(i32 %X) nounwind {
180 ; X86-LABEL: t32_6_3:
182 ; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB
183 ; X86-NEXT: decl %eax
184 ; X86-NEXT: rorl %eax
185 ; X86-NEXT: cmpl $715827883, %eax # imm = 0x2AAAAAAB
189 ; X64-LABEL: t32_6_3:
191 ; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB
192 ; X64-NEXT: decl %eax
193 ; X64-NEXT: rorl %eax
194 ; X64-NEXT: cmpl $715827883, %eax # imm = 0x2AAAAAAB
197 %urem = urem i32 %X, 6
198 %cmp = icmp eq i32 %urem, 3
202 define i1 @t32_6_4(i32 %X) nounwind {
203 ; X86-LABEL: t32_6_4:
205 ; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB
206 ; X86-NEXT: addl $1431655764, %eax # imm = 0x55555554
207 ; X86-NEXT: rorl %eax
208 ; X86-NEXT: cmpl $715827882, %eax # imm = 0x2AAAAAAA
212 ; X64-LABEL: t32_6_4:
214 ; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB
215 ; X64-NEXT: addl $1431655764, %eax # imm = 0x55555554
216 ; X64-NEXT: rorl %eax
217 ; X64-NEXT: cmpl $715827882, %eax # imm = 0x2AAAAAAA
220 %urem = urem i32 %X, 6
221 %cmp = icmp eq i32 %urem, 4
225 define i1 @t32_6_5(i32 %X) nounwind {
226 ; X86-LABEL: t32_6_5:
228 ; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %eax # imm = 0xAAAAAAAB
229 ; X86-NEXT: addl $-1431655767, %eax # imm = 0xAAAAAAA9
230 ; X86-NEXT: rorl %eax
231 ; X86-NEXT: cmpl $715827882, %eax # imm = 0x2AAAAAAA
235 ; X64-LABEL: t32_6_5:
237 ; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB
238 ; X64-NEXT: addl $-1431655767, %eax # imm = 0xAAAAAAA9
239 ; X64-NEXT: rorl %eax
240 ; X64-NEXT: cmpl $715827882, %eax # imm = 0x2AAAAAAA
243 %urem = urem i32 %X, 6
244 %cmp = icmp eq i32 %urem, 5
248 ;-------------------------------------------------------------------------------
251 define i1 @t16_3_2(i16 %X) nounwind {
252 ; X86-LABEL: t16_3_2:
254 ; X86-NEXT: imull $-21845, {{[0-9]+}}(%esp), %eax # imm = 0xAAAB
255 ; X86-NEXT: addl $-21846, %eax # imm = 0xAAAA
256 ; X86-NEXT: movzwl %ax, %eax
257 ; X86-NEXT: cmpl $21845, %eax # imm = 0x5555
261 ; X64-LABEL: t16_3_2:
263 ; X64-NEXT: imull $-21845, %edi, %eax # imm = 0xAAAB
264 ; X64-NEXT: addl $-21846, %eax # imm = 0xAAAA
265 ; X64-NEXT: movzwl %ax, %eax
266 ; X64-NEXT: cmpl $21845, %eax # imm = 0x5555
269 %urem = urem i16 %X, 3
270 %cmp = icmp eq i16 %urem, 2
274 define i1 @t8_3_2(i8 %X) nounwind {
277 ; X86-NEXT: imull $-85, {{[0-9]+}}(%esp), %eax
278 ; X86-NEXT: addb $-86, %al
279 ; X86-NEXT: cmpb $85, %al
285 ; X64-NEXT: imull $-85, %edi, %eax
286 ; X64-NEXT: addb $-86, %al
287 ; X64-NEXT: cmpb $85, %al
290 %urem = urem i8 %X, 3
291 %cmp = icmp eq i8 %urem, 2
295 define i1 @t64_3_2(i64 %X) nounwind {
296 ; X86-LABEL: t64_3_2:
298 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
299 ; X86-NEXT: movl $-1431655765, %edx # imm = 0xAAAAAAAB
300 ; X86-NEXT: movl %ecx, %eax
301 ; X86-NEXT: mull %edx
302 ; X86-NEXT: imull $-1431655766, %ecx, %ecx # imm = 0xAAAAAAAA
303 ; X86-NEXT: addl %edx, %ecx
304 ; X86-NEXT: imull $-1431655765, {{[0-9]+}}(%esp), %edx # imm = 0xAAAAAAAB
305 ; X86-NEXT: addl %ecx, %edx
306 ; X86-NEXT: addl $-1431655766, %eax # imm = 0xAAAAAAAA
307 ; X86-NEXT: adcl $-1431655766, %edx # imm = 0xAAAAAAAA
308 ; X86-NEXT: cmpl $1431655765, %eax # imm = 0x55555555
309 ; X86-NEXT: sbbl $1431655765, %edx # imm = 0x55555555
313 ; X64-LABEL: t64_3_2:
315 ; X64-NEXT: movabsq $-6148914691236517205, %rax # imm = 0xAAAAAAAAAAAAAAAB
316 ; X64-NEXT: imulq %rdi, %rax
317 ; X64-NEXT: movabsq $-6148914691236517206, %rcx # imm = 0xAAAAAAAAAAAAAAAA
318 ; X64-NEXT: addq %rax, %rcx
319 ; X64-NEXT: movabsq $6148914691236517205, %rax # imm = 0x5555555555555555
320 ; X64-NEXT: cmpq %rax, %rcx
323 %urem = urem i64 %X, 3
324 %cmp = icmp eq i64 %urem, 2