1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686--| FileCheck %s --check-prefixes=X86
3 ; RUN: llc < %s -mtriple=x86_64--| FileCheck %s --check-prefixes=X64
9 declare void @on_less()
10 declare void @on_equal()
11 declare void @on_greater()
13 define void @eq_first(i32 %0, i32 %1) {
14 ; X86-LABEL: eq_first:
16 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
17 ; X86-NEXT: cmpl %eax, {{[0-9]+}}(%esp)
18 ; X86-NEXT: jl on_less@PLT # TAILCALL
20 ; X86-NEXT: je on_equal@PLT # TAILCALL
22 ; X86-NEXT: jmp on_greater@PLT # TAILCALL
24 ; X64-LABEL: eq_first:
26 ; X64-NEXT: cmpl %esi, %edi
27 ; X64-NEXT: jl on_less@PLT # TAILCALL
29 ; X64-NEXT: je on_equal@PLT # TAILCALL
31 ; X64-NEXT: jmp on_greater@PLT # TAILCALL
32 %3 = icmp slt i32 %0, %1
33 br i1 %3, label %4, label %5
35 tail call void @on_less()
38 %6 = icmp eq i32 %0, %1
39 br i1 %6, label %7, label %8
41 tail call void @on_equal()
44 tail call void @on_greater()
50 define void @gt_first(i32 %0, i32 %1) {
51 ; X86-LABEL: gt_first:
53 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
54 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
55 ; X86-NEXT: cmpl %eax, %ecx
56 ; X86-NEXT: jl on_less@PLT # TAILCALL
58 ; X86-NEXT: jg on_greater@PLT # TAILCALL
60 ; X86-NEXT: jmp on_equal@PLT # TAILCALL
62 ; X64-LABEL: gt_first:
64 ; X64-NEXT: cmpl %esi, %edi
65 ; X64-NEXT: jl on_less@PLT # TAILCALL
67 ; X64-NEXT: jg on_greater@PLT # TAILCALL
69 ; X64-NEXT: jmp on_equal@PLT # TAILCALL
70 %3 = icmp slt i32 %0, %1
71 br i1 %3, label %4, label %5
73 tail call void @on_less()
76 %6 = icmp slt i32 %1, %0
77 br i1 %6, label %7, label %8
79 tail call void @on_greater()
82 tail call void @on_equal()
88 define void @cmp_sub_same_order(i32 %x, i32 %y, ptr %p) {
89 ; X86-LABEL: cmp_sub_same_order:
90 ; X86: # %bb.0: # %entry
91 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
92 ; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
93 ; X86-NEXT: jge .LBB2_2
94 ; X86-NEXT: # %bb.1: # %cond.true
95 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
96 ; X86-NEXT: movl %eax, (%ecx)
97 ; X86-NEXT: .LBB2_2: # %cond.end
100 ; X64-LABEL: cmp_sub_same_order:
101 ; X64: # %bb.0: # %entry
102 ; X64-NEXT: subl %esi, %edi
103 ; X64-NEXT: jge .LBB2_2
104 ; X64-NEXT: # %bb.1: # %cond.true
105 ; X64-NEXT: movl %edi, (%rdx)
106 ; X64-NEXT: .LBB2_2: # %cond.end
109 %cmp = icmp slt i32 %x, %y
110 br i1 %cmp, label %cond.true, label %cond.end
113 %sub = sub nsw i32 %x, %y
114 store i32 %sub, ptr %p
121 define void @cmp_sub_different_order(i32 %x, i32 %y, ptr %p) {
122 ; X86-LABEL: cmp_sub_different_order:
123 ; X86: # %bb.0: # %entry
124 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
125 ; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
126 ; X86-NEXT: jge .LBB3_2
127 ; X86-NEXT: # %bb.1: # %cond.true
128 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
129 ; X86-NEXT: movl %eax, (%ecx)
130 ; X86-NEXT: .LBB3_2: # %cond.end
133 ; X64-LABEL: cmp_sub_different_order:
134 ; X64: # %bb.0: # %entry
135 ; X64-NEXT: subl %esi, %edi
136 ; X64-NEXT: jge .LBB3_2
137 ; X64-NEXT: # %bb.1: # %cond.true
138 ; X64-NEXT: movl %edi, (%rdx)
139 ; X64-NEXT: .LBB3_2: # %cond.end
142 %cmp = icmp sgt i32 %y, %x
143 br i1 %cmp, label %cond.true, label %cond.end
146 %sub = sub nsw i32 %x, %y
147 store i32 %sub, ptr %p
154 declare void @use(i32)