1 ; Example input for update_llc_test_checks (taken from CodeGen/X86/iabs.ll)
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefix=X86 --check-prefix=X86-NO-CMOV
3 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+cmov | FileCheck %s --check-prefix=X86 --check-prefix=X86-CMOV
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=X64
6 define i8 @test_i8(i8 %a) nounwind {
9 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
10 ; X86-NEXT: movl %eax, %ecx
11 ; X86-NEXT: sarb $7, %cl
12 ; X86-NEXT: xorb %cl, %al
13 ; X86-NEXT: subb %cl, %al
18 ; X64-NEXT: movl %edi, %eax
19 ; X64-NEXT: movl %eax, %ecx
20 ; X64-NEXT: sarb $7, %cl
21 ; X64-NEXT: xorb %cl, %al
22 ; X64-NEXT: subb %cl, %al
23 ; X64-NEXT: # kill: def $al killed $al killed $eax
25 %tmp1neg = sub i8 0, %a
26 %b = icmp sgt i8 %a, -1
27 %abs = select i1 %b, i8 %a, i8 %tmp1neg
31 define i16 @test_i16(i16 %a) nounwind {
32 ; X86-NO-CMOV-LABEL: test_i16:
33 ; X86-NO-CMOV: # %bb.0:
34 ; X86-NO-CMOV-NEXT: movzwl {{[0-9]+}}(%esp), %eax
35 ; X86-NO-CMOV-NEXT: movswl %ax, %ecx
36 ; X86-NO-CMOV-NEXT: sarl $15, %ecx
37 ; X86-NO-CMOV-NEXT: xorl %ecx, %eax
38 ; X86-NO-CMOV-NEXT: subl %ecx, %eax
39 ; X86-NO-CMOV-NEXT: # kill: def $ax killed $ax killed $eax
40 ; X86-NO-CMOV-NEXT: retl
42 ; X86-CMOV-LABEL: test_i16:
44 ; X86-CMOV-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
45 ; X86-CMOV-NEXT: movl %ecx, %eax
46 ; X86-CMOV-NEXT: negw %ax
47 ; X86-CMOV-NEXT: cmovsw %cx, %ax
50 ; X64-LABEL: test_i16:
52 ; X64-NEXT: movl %edi, %eax
54 ; X64-NEXT: cmovsw %di, %ax
56 %tmp1neg = sub i16 0, %a
57 %b = icmp sgt i16 %a, -1
58 %abs = select i1 %b, i16 %a, i16 %tmp1neg
62 define i32 @test_i32(i32 %a) nounwind {
63 ; X86-NO-CMOV-LABEL: test_i32:
64 ; X86-NO-CMOV: # %bb.0:
65 ; X86-NO-CMOV-NEXT: movl {{[0-9]+}}(%esp), %eax
66 ; X86-NO-CMOV-NEXT: movl %eax, %ecx
67 ; X86-NO-CMOV-NEXT: sarl $31, %ecx
68 ; X86-NO-CMOV-NEXT: xorl %ecx, %eax
69 ; X86-NO-CMOV-NEXT: subl %ecx, %eax
70 ; X86-NO-CMOV-NEXT: retl
72 ; X86-CMOV-LABEL: test_i32:
74 ; X86-CMOV-NEXT: movl {{[0-9]+}}(%esp), %ecx
75 ; X86-CMOV-NEXT: movl %ecx, %eax
76 ; X86-CMOV-NEXT: negl %eax
77 ; X86-CMOV-NEXT: cmovsl %ecx, %eax
80 ; X64-LABEL: test_i32:
82 ; X64-NEXT: movl %edi, %eax
84 ; X64-NEXT: cmovsl %edi, %eax
86 %tmp1neg = sub i32 0, %a
87 %b = icmp sgt i32 %a, -1
88 %abs = select i1 %b, i32 %a, i32 %tmp1neg
92 define i64 @test_i64(i64 %a) nounwind {
93 ; X86-LABEL: test_i64:
95 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
96 ; X86-NEXT: movl %edx, %ecx
97 ; X86-NEXT: sarl $31, %ecx
98 ; X86-NEXT: xorl %ecx, %edx
99 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
100 ; X86-NEXT: xorl %ecx, %eax
101 ; X86-NEXT: subl %ecx, %eax
102 ; X86-NEXT: sbbl %ecx, %edx
105 ; X64-LABEL: test_i64:
107 ; X64-NEXT: movq %rdi, %rax
108 ; X64-NEXT: negq %rax
109 ; X64-NEXT: cmovsq %rdi, %rax
111 %tmp1neg = sub i64 0, %a
112 %b = icmp sgt i64 %a, -1
113 %abs = select i1 %b, i64 %a, i64 %tmp1neg