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
14 ; X86-NEXT: xorl %edx, %edx
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
32 ; X64-NEXT: xorl %edx, %edx
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: cmpl $858993460, %eax # imm = 0x33333334
52 ; X86-NEXT: movl $42, %eax
53 ; X86-NEXT: jb .LBB1_2
55 ; X86-NEXT: movl $-10, %eax
59 ; X64-LABEL: test_optsize:
61 ; X64-NEXT: imull $-858993459, %edi, %eax # imm = 0xCCCCCCCD
62 ; X64-NEXT: cmpl $858993460, %eax # imm = 0x33333334
63 ; X64-NEXT: movl $42, %ecx
64 ; X64-NEXT: movl $-10, %eax
65 ; X64-NEXT: cmovbl %ecx, %eax
68 %cmp = icmp eq i32 %rem, 0
69 %ret = select i1 %cmp, i32 42, i32 -10