1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=i686--| FileCheck %s --check-prefixes=X86
; RUN: llc < %s -mtriple=x86_64--| FileCheck %s --check-prefixes=X64
;
; PR35202
;
declare void @on_less()
declare void @on_equal()
declare void @on_greater()
define void @eq_first(i32 %0, i32 %1) {
; X86-LABEL: eq_first:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: cmpl %eax, {{[0-9]+}}(%esp)
; X86-NEXT: jl on_less@PLT # TAILCALL
; X86-NEXT: # %bb.1:
; X86-NEXT: je on_equal@PLT # TAILCALL
; X86-NEXT: # %bb.2:
; X86-NEXT: jmp on_greater@PLT # TAILCALL
;
; X64-LABEL: eq_first:
; X64: # %bb.0:
; X64-NEXT: cmpl %esi, %edi
; X64-NEXT: jl on_less@PLT # TAILCALL
; X64-NEXT: # %bb.1:
; X64-NEXT: je on_equal@PLT # TAILCALL
; X64-NEXT: # %bb.2:
; X64-NEXT: jmp on_greater@PLT # TAILCALL
%3 = icmp slt i32 %0, %1
br i1 %3, label %4, label %5
4:
tail call void @on_less()
br label %9
5:
%6 = icmp eq i32 %0, %1
br i1 %6, label %7, label %8
7:
tail call void @on_equal()
br label %9
8:
tail call void @on_greater()
br label %9
9:
ret void
}
define void @gt_first(i32 %0, i32 %1) {
; X86-LABEL: gt_first:
; X86: # %bb.0:
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT: cmpl %eax, %ecx
; X86-NEXT: jl on_less@PLT # TAILCALL
; X86-NEXT: # %bb.1:
; X86-NEXT: jg on_greater@PLT # TAILCALL
; X86-NEXT: # %bb.2:
; X86-NEXT: jmp on_equal@PLT # TAILCALL
;
; X64-LABEL: gt_first:
; X64: # %bb.0:
; X64-NEXT: cmpl %esi, %edi
; X64-NEXT: jl on_less@PLT # TAILCALL
; X64-NEXT: # %bb.1:
; X64-NEXT: jg on_greater@PLT # TAILCALL
; X64-NEXT: # %bb.2:
; X64-NEXT: jmp on_equal@PLT # TAILCALL
%3 = icmp slt i32 %0, %1
br i1 %3, label %4, label %5
4:
tail call void @on_less()
br label %9
5:
%6 = icmp slt i32 %1, %0
br i1 %6, label %7, label %8
7:
tail call void @on_greater()
br label %9
8:
tail call void @on_equal()
br label %9
9:
ret void
}
define void @cmp_sub_same_order(i32 %x, i32 %y, ptr %p) {
; X86-LABEL: cmp_sub_same_order:
; X86: # %bb.0: # %entry
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
; X86-NEXT: jge .LBB2_2
; X86-NEXT: # %bb.1: # %cond.true
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT: movl %eax, (%ecx)
; X86-NEXT: .LBB2_2: # %cond.end
; X86-NEXT: retl
;
; X64-LABEL: cmp_sub_same_order:
; X64: # %bb.0: # %entry
; X64-NEXT: subl %esi, %edi
; X64-NEXT: jge .LBB2_2
; X64-NEXT: # %bb.1: # %cond.true
; X64-NEXT: movl %edi, (%rdx)
; X64-NEXT: .LBB2_2: # %cond.end
; X64-NEXT: retq
entry:
%cmp = icmp slt i32 %x, %y
br i1 %cmp, label %cond.true, label %cond.end
cond.true:
%sub = sub nsw i32 %x, %y
store i32 %sub, ptr %p
br label %cond.end
cond.end:
ret void
}
define void @cmp_sub_different_order(i32 %x, i32 %y, ptr %p) {
; X86-LABEL: cmp_sub_different_order:
; X86: # %bb.0: # %entry
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
; X86-NEXT: subl {{[0-9]+}}(%esp), %eax
; X86-NEXT: jge .LBB3_2
; X86-NEXT: # %bb.1: # %cond.true
; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
; X86-NEXT: movl %eax, (%ecx)
; X86-NEXT: .LBB3_2: # %cond.end
; X86-NEXT: retl
;
; X64-LABEL: cmp_sub_different_order:
; X64: # %bb.0: # %entry
; X64-NEXT: subl %esi, %edi
; X64-NEXT: jge .LBB3_2
; X64-NEXT: # %bb.1: # %cond.true
; X64-NEXT: movl %edi, (%rdx)
; X64-NEXT: .LBB3_2: # %cond.end
; X64-NEXT: retq
entry:
%cmp = icmp sgt i32 %y, %x
br i1 %cmp, label %cond.true, label %cond.end
cond.true:
%sub = sub nsw i32 %x, %y
store i32 %sub, ptr %p
br label %cond.end
cond.end:
ret void
}
declare void @use(i32)
|