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-prefixes=CHECK,X86
3 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,X64
5 ; On X86, division in expensive. BuildRemEqFold should therefore run even
6 ; when optimizing for size. Only optimizing for minimum size retains a plain div.
8 define i32 @test_minsize(i32 %X) optsize minsize nounwind readnone {
9 ; X86-LABEL: test_minsize:
11 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
15 ; X86-NEXT: idivl %ecx
16 ; X86-NEXT: testl %edx, %edx
17 ; X86-NEXT: je .LBB0_1
19 ; X86-NEXT: pushl $-10
27 ; X64-LABEL: test_minsize:
29 ; X64-NEXT: movl %edi, %eax
33 ; X64-NEXT: idivl %ecx
34 ; X64-NEXT: testl %edx, %edx
37 ; X64-NEXT: pushq $-10
39 ; X64-NEXT: cmovel %ecx, %eax
42 %cmp = icmp eq i32 %rem, 0
43 %ret = select i1 %cmp, i32 42, i32 -10
47 define i32 @test_optsize(i32 %X) optsize nounwind readnone {
48 ; X86-LABEL: test_optsize:
50 ; X86-NEXT: imull $-858993459, {{[0-9]+}}(%esp), %eax # imm = 0xCCCCCCCD
51 ; X86-NEXT: addl $429496729, %eax # imm = 0x19999999
52 ; X86-NEXT: cmpl $858993459, %eax # imm = 0x33333333
53 ; X86-NEXT: movl $42, %eax
54 ; X86-NEXT: jb .LBB1_2
56 ; X86-NEXT: movl $-10, %eax
60 ; X64-LABEL: test_optsize:
62 ; X64-NEXT: imull $-858993459, %edi, %eax # imm = 0xCCCCCCCD
63 ; X64-NEXT: addl $429496729, %eax # imm = 0x19999999
64 ; X64-NEXT: cmpl $858993459, %eax # imm = 0x33333333
65 ; X64-NEXT: movl $42, %ecx
66 ; X64-NEXT: movl $-10, %eax
67 ; X64-NEXT: cmovbl %ecx, %eax
70 %cmp = icmp eq i32 %rem, 0
71 %ret = select i1 %cmp, i32 42, i32 -10