1 ; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+cmov %s -o - | FileCheck %s --check-prefix=CHECK32
2 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+cmov %s -o - | FileCheck %s --check-prefix=CHECK64
4 define i32 @one32() optsize {
9 ; CHECK32: xorl %eax, %eax
10 ; CHECK32-NEXT: incl %eax
13 ; FIXME: Figure out the best approach in 64-bit mode.
14 ; CHECK64-LABEL: one32
15 ; CHECK64: movl $1, %eax
19 define i32 @minus_one32() optsize {
23 ; CHECK32-LABEL: minus_one32
24 ; CHECK32: xorl %eax, %eax
25 ; CHECK32-NEXT: decl %eax
29 define i16 @one16() optsize {
33 ; CHECK32-LABEL: one16
34 ; CHECK32: xorl %eax, %eax
35 ; CHECK32-NEXT: incl %eax
39 define i16 @minus_one16() optsize {
43 ; CHECK32-LABEL: minus_one16
44 ; CHECK32: xorl %eax, %eax
45 ; CHECK32-NEXT: decl %eax
49 define i32 @test_rematerialization() optsize {
51 ; Materialize -1 (thiscall forces it into %ecx).
52 tail call x86_thiscallcc void @f(i32 -1)
54 ; Clobber all registers except %esp, leaving nowhere to store the -1 besides
55 ; spilling it to the stack.
56 tail call void asm sideeffect "", "~{eax},~{ebx},~{ecx},~{edx},~{edi},~{esi},~{ebp},~{dirflag},~{fpsr},~{flags}"()
58 ; -1 should be re-materialized here instead of getting spilled above.
61 ; CHECK32-LABEL: test_rematerialization
62 ; CHECK32: xorl %ecx, %ecx
63 ; CHECK32-NEXT: decl %ecx
65 ; CHECK32: xorl %eax, %eax
66 ; CHECK32-NEXT: decl %eax
71 define i32 @test_rematerialization2(i32 %x) optsize {
73 ; Materialize -1 (thiscall forces it into %ecx).
74 tail call x86_thiscallcc void @f(i32 -1)
76 ; Clobber all registers except %esp, leaving nowhere to store the -1 besides
77 ; spilling it to the stack.
78 tail call void asm sideeffect "", "~{eax},~{ebx},~{ecx},~{edx},~{edi},~{esi},~{ebp},~{dirflag},~{fpsr},~{flags}"()
81 %a = icmp ne i32 %x, 123
82 %b = zext i1 %a to i32
83 ; Cause -1 to be rematerialized right in front of the cmov, which needs eflags.
84 ; It must therefore not use the xor-dec lowering.
85 %c = select i1 %a, i32 %b, i32 -1
88 ; CHECK32-LABEL: test_rematerialization2
89 ; CHECK32: xorl %ecx, %ecx
90 ; CHECK32-NEXT: decl %ecx
100 declare x86_thiscallcc void @f(i32)