llvm.org GIT mirror llvm / df4f3da
Merging r329040 with re-generated CHECK lines via the script. The CHECK lines in the trunk version don't work due to unrelated (unmerged) changes to the backend. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@332900 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 1 year, 5 months ago
1 changed file(s) with 413 addition(s) and 142 deletion(s). Raw diff Collapse all Expand all
None ; RUN: llc -mtriple=i386-linux-gnu %s -o - | FileCheck %s -check-prefix=i386
1 ; RUN: llc -mtriple=i386-linux-gnu -pre-RA-sched=fast %s -o - | FileCheck %s -check-prefix=i386f
2
3 ; RUN: llc -mtriple=x86_64-linux-gnu %s -o - | FileCheck %s -check-prefix=x8664
4 ; RUN: llc -mtriple=x86_64-linux-gnu -pre-RA-sched=fast %s -o - | FileCheck %s -check-prefix=x8664
5 ; RUN: llc -mtriple=x86_64-linux-gnu -mattr=+sahf %s -o - | FileCheck %s -check-prefix=x8664-sahf
6 ; RUN: llc -mtriple=x86_64-linux-gnu -mattr=+sahf -pre-RA-sched=fast %s -o - | FileCheck %s -check-prefix=x8664-sahf
7 ; RUN: llc -mtriple=x86_64-linux-gnu -mcpu=corei7 %s -o - | FileCheck %s -check-prefix=x8664-sahf
0 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
1 ; RUN: llc -mtriple=i386-linux-gnu %s -o - | FileCheck %s --check-prefixes=32-ALL,32-GOOD-RA
2 ; RUN: llc -mtriple=i386-linux-gnu -pre-RA-sched=fast %s -o - | FileCheck %s --check-prefixes=32-ALL,32-FAST-RA
3
4 ; RUN: llc -mtriple=x86_64-linux-gnu %s -o - | FileCheck %s --check-prefixes=64-ALL,64-GOOD-RA
5 ; RUN: llc -mtriple=x86_64-linux-gnu -pre-RA-sched=fast %s -o - | FileCheck %s --check-prefixes=64-ALL,64-FAST-RA
6 ; RUN: llc -mtriple=x86_64-linux-gnu -mattr=+sahf %s -o - | FileCheck %s --check-prefixes=64-ALL,64-GOOD-RA-SAHF
7 ; RUN: llc -mtriple=x86_64-linux-gnu -mattr=+sahf -pre-RA-sched=fast %s -o - | FileCheck %s --check-prefixes=64-ALL,64-FAST-RA-SAHF
8 ; RUN: llc -mtriple=x86_64-linux-gnu -mcpu=corei7 %s -o - | FileCheck %s --check-prefixes=64-ALL,64-GOOD-RA-SAHF
89
910 ; TODO: Reenable verify-machineinstr once the if (!AXDead) // FIXME
1011 ; in X86InstrInfo::copyPhysReg() is resolved.
1213 declare i32 @foo()
1314 declare i32 @bar(i64)
1415
15 define i64 @test_intervening_call(i64* %foo, i64 %bar, i64 %baz) {
16 ; i386-LABEL: test_intervening_call:
17 ; i386: cmpxchg8b
18 ; i386-NEXT: pushl %eax
19 ; i386-NEXT: seto %al
20 ; i386-NEXT: lahf
21 ; i386-NEXT: movl %eax, [[FLAGS:%.*]]
22 ; i386-NEXT: popl %eax
23 ; i386-NEXT: subl $8, %esp
24 ; i386-NEXT: pushl %edx
25 ; i386-NEXT: pushl %eax
26 ; i386-NEXT: calll bar
27 ; i386-NEXT: addl $16, %esp
28 ; i386-NEXT: movl [[FLAGS]], %eax
29 ; i386-NEXT: addb $127, %al
30 ; i386-NEXT: sahf
31 ; i386-NEXT: jne
32
33 ; In the following case we get a long chain of EFLAGS save/restore due to
34 ; a sequence of:
16 ; In the following case when using fast scheduling we get a long chain of
17 ; EFLAGS save/restore due to a sequence of:
3518 ; cmpxchg8b (implicit-def eflags)
3619 ; eax = copy eflags
3720 ; adjcallstackdown32
4326 ; happens with the fast pre-regalloc scheduler enforced. A more
4427 ; performant scheduler would move the adjcallstackdown32 out of the
4528 ; eflags liveness interval.
46
47 ; i386f-LABEL: test_intervening_call:
48 ; i386f: cmpxchg8b
49 ; i386f-NEXT: pushl %eax
50 ; i386f-NEXT: seto %al
51 ; i386f-NEXT: lahf
52 ; i386f-NEXT: movl %eax, [[FLAGS:%.*]]
53 ; i386f-NEXT: popl %eax
54 ; i386f-NEXT: subl $8, %esp
55 ; i386f-NEXT: pushl %eax
56 ; i386f-NEXT: movl %ecx, %eax
57 ; i386f-NEXT: addb $127, %al
58 ; i386f-NEXT: sahf
59 ; i386f-NEXT: popl %eax
60 ; i386f-NEXT: pushl %eax
61 ; i386f-NEXT: seto %al
62 ; i386f-NEXT: lahf
63 ; i386f-NEXT: movl %eax, %esi
64 ; i386f-NEXT: popl %eax
65 ; i386f-NEXT: pushl %edx
66 ; i386f-NEXT: pushl %eax
67 ; i386f-NEXT: calll bar
68 ; i386f-NEXT: addl $16, %esp
69 ; i386f-NEXT: movl %esi, %eax
70 ; i386f-NEXT: addb $127, %al
71
72 ; x8664-LABEL: test_intervening_call:
73 ; x8664: cmpxchgq
74 ; x8664: pushfq
75 ; x8664-NEXT: popq [[FLAGS:%.*]]
76 ; x8664-NEXT: movq %rax, %rdi
77 ; x8664-NEXT: callq bar
78 ; x8664-NEXT: pushq [[FLAGS]]
79 ; x8664-NEXT: popfq
80 ; x8664-NEXT: jne
81
82 ; x8664-sahf-LABEL: test_intervening_call:
83 ; x8664-sahf: cmpxchgq
84 ; x8664-sahf: pushq %rax
85 ; x8664-sahf-NEXT: seto %al
86 ; x8664-sahf-NEXT: lahf
87 ; x8664-sahf-NEXT: movq %rax, [[FLAGS:%.*]]
88 ; x8664-sahf-NEXT: popq %rax
89 ; x8664-sahf-NEXT: movq %rax, %rdi
90 ; x8664-sahf-NEXT: callq bar
91 ; RAX is dead, no need to push and pop it.
92 ; x8664-sahf-NEXT: movq [[FLAGS]], %rax
93 ; x8664-sahf-NEXT: addb $127, %al
94 ; x8664-sahf-NEXT: sahf
95 ; x8664-sahf-NEXT: jne
96
29 define i64 @test_intervening_call(i64* %foo, i64 %bar, i64 %baz) nounwind {
30 ; 32-GOOD-RA-LABEL: test_intervening_call:
31 ; 32-GOOD-RA: # %bb.0: # %entry
32 ; 32-GOOD-RA-NEXT: pushl %ebp
33 ; 32-GOOD-RA-NEXT: movl %esp, %ebp
34 ; 32-GOOD-RA-NEXT: pushl %ebx
35 ; 32-GOOD-RA-NEXT: pushl %esi
36 ; 32-GOOD-RA-NEXT: movl 12(%ebp), %eax
37 ; 32-GOOD-RA-NEXT: movl 16(%ebp), %edx
38 ; 32-GOOD-RA-NEXT: movl 20(%ebp), %ebx
39 ; 32-GOOD-RA-NEXT: movl 24(%ebp), %ecx
40 ; 32-GOOD-RA-NEXT: movl 8(%ebp), %esi
41 ; 32-GOOD-RA-NEXT: lock cmpxchg8b (%esi)
42 ; 32-GOOD-RA-NEXT: pushl %eax
43 ; 32-GOOD-RA-NEXT: seto %al
44 ; 32-GOOD-RA-NEXT: lahf
45 ; 32-GOOD-RA-NEXT: movl %eax, %esi
46 ; 32-GOOD-RA-NEXT: popl %eax
47 ; 32-GOOD-RA-NEXT: subl $8, %esp
48 ; 32-GOOD-RA-NEXT: pushl %edx
49 ; 32-GOOD-RA-NEXT: pushl %eax
50 ; 32-GOOD-RA-NEXT: calll bar
51 ; 32-GOOD-RA-NEXT: addl $16, %esp
52 ; 32-GOOD-RA-NEXT: movl %esi, %eax
53 ; 32-GOOD-RA-NEXT: addb $127, %al
54 ; 32-GOOD-RA-NEXT: sahf
55 ; 32-GOOD-RA-NEXT: jne .LBB0_3
56 ; 32-GOOD-RA-NEXT: # %bb.1: # %t
57 ; 32-GOOD-RA-NEXT: movl $42, %eax
58 ; 32-GOOD-RA-NEXT: jmp .LBB0_2
59 ; 32-GOOD-RA-NEXT: .LBB0_3: # %f
60 ; 32-GOOD-RA-NEXT: xorl %eax, %eax
61 ; 32-GOOD-RA-NEXT: .LBB0_2: # %t
62 ; 32-GOOD-RA-NEXT: xorl %edx, %edx
63 ; 32-GOOD-RA-NEXT: popl %esi
64 ; 32-GOOD-RA-NEXT: popl %ebx
65 ; 32-GOOD-RA-NEXT: popl %ebp
66 ; 32-GOOD-RA-NEXT: retl
67 ;
68 ; 32-FAST-RA-LABEL: test_intervening_call:
69 ; 32-FAST-RA: # %bb.0: # %entry
70 ; 32-FAST-RA-NEXT: pushl %ebp
71 ; 32-FAST-RA-NEXT: movl %esp, %ebp
72 ; 32-FAST-RA-NEXT: pushl %ebx
73 ; 32-FAST-RA-NEXT: pushl %esi
74 ; 32-FAST-RA-NEXT: movl 8(%ebp), %esi
75 ; 32-FAST-RA-NEXT: movl 20(%ebp), %ebx
76 ; 32-FAST-RA-NEXT: movl 24(%ebp), %ecx
77 ; 32-FAST-RA-NEXT: movl 12(%ebp), %eax
78 ; 32-FAST-RA-NEXT: movl 16(%ebp), %edx
79 ; 32-FAST-RA-NEXT: lock cmpxchg8b (%esi)
80 ; 32-FAST-RA-NEXT: pushl %eax
81 ; 32-FAST-RA-NEXT: seto %al
82 ; 32-FAST-RA-NEXT: lahf
83 ; 32-FAST-RA-NEXT: movl %eax, %ecx
84 ; 32-FAST-RA-NEXT: popl %eax
85 ; 32-FAST-RA-NEXT: subl $8, %esp
86 ; 32-FAST-RA-NEXT: pushl %eax
87 ; 32-FAST-RA-NEXT: movl %ecx, %eax
88 ; 32-FAST-RA-NEXT: addb $127, %al
89 ; 32-FAST-RA-NEXT: sahf
90 ; 32-FAST-RA-NEXT: popl %eax
91 ; 32-FAST-RA-NEXT: pushl %eax
92 ; 32-FAST-RA-NEXT: seto %al
93 ; 32-FAST-RA-NEXT: lahf
94 ; 32-FAST-RA-NEXT: movl %eax, %esi
95 ; 32-FAST-RA-NEXT: popl %eax
96 ; 32-FAST-RA-NEXT: pushl %edx
97 ; 32-FAST-RA-NEXT: pushl %eax
98 ; 32-FAST-RA-NEXT: calll bar
99 ; 32-FAST-RA-NEXT: addl $16, %esp
100 ; 32-FAST-RA-NEXT: movl %esi, %eax
101 ; 32-FAST-RA-NEXT: addb $127, %al
102 ; 32-FAST-RA-NEXT: sahf
103 ; 32-FAST-RA-NEXT: jne .LBB0_3
104 ; 32-FAST-RA-NEXT: # %bb.1: # %t
105 ; 32-FAST-RA-NEXT: movl $42, %eax
106 ; 32-FAST-RA-NEXT: jmp .LBB0_2
107 ; 32-FAST-RA-NEXT: .LBB0_3: # %f
108 ; 32-FAST-RA-NEXT: xorl %eax, %eax
109 ; 32-FAST-RA-NEXT: .LBB0_2: # %t
110 ; 32-FAST-RA-NEXT: xorl %edx, %edx
111 ; 32-FAST-RA-NEXT: popl %esi
112 ; 32-FAST-RA-NEXT: popl %ebx
113 ; 32-FAST-RA-NEXT: popl %ebp
114 ; 32-FAST-RA-NEXT: retl
115 ;
116 ; 64-GOOD-RA-LABEL: test_intervening_call:
117 ; 64-GOOD-RA: # %bb.0: # %entry
118 ; 64-GOOD-RA-NEXT: pushq %rbp
119 ; 64-GOOD-RA-NEXT: movq %rsp, %rbp
120 ; 64-GOOD-RA-NEXT: pushq %rbx
121 ; 64-GOOD-RA-NEXT: pushq %rax
122 ; 64-GOOD-RA-NEXT: movq %rsi, %rax
123 ; 64-GOOD-RA-NEXT: lock cmpxchgq %rdx, (%rdi)
124 ; 64-GOOD-RA-NEXT: pushfq
125 ; 64-GOOD-RA-NEXT: popq %rbx
126 ; 64-GOOD-RA-NEXT: movq %rax, %rdi
127 ; 64-GOOD-RA-NEXT: callq bar
128 ; 64-GOOD-RA-NEXT: pushq %rbx
129 ; 64-GOOD-RA-NEXT: popfq
130 ; 64-GOOD-RA-NEXT: jne .LBB0_3
131 ; 64-GOOD-RA-NEXT: # %bb.1: # %t
132 ; 64-GOOD-RA-NEXT: movl $42, %eax
133 ; 64-GOOD-RA-NEXT: jmp .LBB0_2
134 ; 64-GOOD-RA-NEXT: .LBB0_3: # %f
135 ; 64-GOOD-RA-NEXT: xorl %eax, %eax
136 ; 64-GOOD-RA-NEXT: .LBB0_2: # %t
137 ; 64-GOOD-RA-NEXT: addq $8, %rsp
138 ; 64-GOOD-RA-NEXT: popq %rbx
139 ; 64-GOOD-RA-NEXT: popq %rbp
140 ; 64-GOOD-RA-NEXT: retq
141 ;
142 ; 64-FAST-RA-LABEL: test_intervening_call:
143 ; 64-FAST-RA: # %bb.0: # %entry
144 ; 64-FAST-RA-NEXT: pushq %rbp
145 ; 64-FAST-RA-NEXT: movq %rsp, %rbp
146 ; 64-FAST-RA-NEXT: pushq %rbx
147 ; 64-FAST-RA-NEXT: pushq %rax
148 ; 64-FAST-RA-NEXT: movq %rsi, %rax
149 ; 64-FAST-RA-NEXT: lock cmpxchgq %rdx, (%rdi)
150 ; 64-FAST-RA-NEXT: pushfq
151 ; 64-FAST-RA-NEXT: popq %rbx
152 ; 64-FAST-RA-NEXT: movq %rax, %rdi
153 ; 64-FAST-RA-NEXT: callq bar
154 ; 64-FAST-RA-NEXT: pushq %rbx
155 ; 64-FAST-RA-NEXT: popfq
156 ; 64-FAST-RA-NEXT: jne .LBB0_3
157 ; 64-FAST-RA-NEXT: # %bb.1: # %t
158 ; 64-FAST-RA-NEXT: movl $42, %eax
159 ; 64-FAST-RA-NEXT: jmp .LBB0_2
160 ; 64-FAST-RA-NEXT: .LBB0_3: # %f
161 ; 64-FAST-RA-NEXT: xorl %eax, %eax
162 ; 64-FAST-RA-NEXT: .LBB0_2: # %t
163 ; 64-FAST-RA-NEXT: addq $8, %rsp
164 ; 64-FAST-RA-NEXT: popq %rbx
165 ; 64-FAST-RA-NEXT: popq %rbp
166 ; 64-FAST-RA-NEXT: retq
167 ;
168 ; 64-GOOD-RA-SAHF-LABEL: test_intervening_call:
169 ; 64-GOOD-RA-SAHF: # %bb.0: # %entry
170 ; 64-GOOD-RA-SAHF-NEXT: pushq %rbp
171 ; 64-GOOD-RA-SAHF-NEXT: movq %rsp, %rbp
172 ; 64-GOOD-RA-SAHF-NEXT: pushq %rbx
173 ; 64-GOOD-RA-SAHF-NEXT: pushq %rax
174 ; 64-GOOD-RA-SAHF-NEXT: movq %rsi, %rax
175 ; 64-GOOD-RA-SAHF-NEXT: lock cmpxchgq %rdx, (%rdi)
176 ; 64-GOOD-RA-SAHF-NEXT: pushq %rax
177 ; 64-GOOD-RA-SAHF-NEXT: seto %al
178 ; 64-GOOD-RA-SAHF-NEXT: lahf
179 ; 64-GOOD-RA-SAHF-NEXT: movq %rax, %rbx
180 ; 64-GOOD-RA-SAHF-NEXT: popq %rax
181 ; 64-GOOD-RA-SAHF-NEXT: movq %rax, %rdi
182 ; 64-GOOD-RA-SAHF-NEXT: callq bar
183 ; 64-GOOD-RA-SAHF-NEXT: movq %rbx, %rax
184 ; 64-GOOD-RA-SAHF-NEXT: addb $127, %al
185 ; 64-GOOD-RA-SAHF-NEXT: sahf
186 ; 64-GOOD-RA-SAHF-NEXT: jne .LBB0_3
187 ; 64-GOOD-RA-SAHF-NEXT: # %bb.1: # %t
188 ; 64-GOOD-RA-SAHF-NEXT: movl $42, %eax
189 ; 64-GOOD-RA-SAHF-NEXT: jmp .LBB0_2
190 ; 64-GOOD-RA-SAHF-NEXT: .LBB0_3: # %f
191 ; 64-GOOD-RA-SAHF-NEXT: xorl %eax, %eax
192 ; 64-GOOD-RA-SAHF-NEXT: .LBB0_2: # %t
193 ; 64-GOOD-RA-SAHF-NEXT: addq $8, %rsp
194 ; 64-GOOD-RA-SAHF-NEXT: popq %rbx
195 ; 64-GOOD-RA-SAHF-NEXT: popq %rbp
196 ; 64-GOOD-RA-SAHF-NEXT: retq
197 ;
198 ; 64-FAST-RA-SAHF-LABEL: test_intervening_call:
199 ; 64-FAST-RA-SAHF: # %bb.0: # %entry
200 ; 64-FAST-RA-SAHF-NEXT: pushq %rbp
201 ; 64-FAST-RA-SAHF-NEXT: movq %rsp, %rbp
202 ; 64-FAST-RA-SAHF-NEXT: pushq %rbx
203 ; 64-FAST-RA-SAHF-NEXT: pushq %rax
204 ; 64-FAST-RA-SAHF-NEXT: movq %rsi, %rax
205 ; 64-FAST-RA-SAHF-NEXT: lock cmpxchgq %rdx, (%rdi)
206 ; 64-FAST-RA-SAHF-NEXT: pushq %rax
207 ; 64-FAST-RA-SAHF-NEXT: seto %al
208 ; 64-FAST-RA-SAHF-NEXT: lahf
209 ; 64-FAST-RA-SAHF-NEXT: movq %rax, %rbx
210 ; 64-FAST-RA-SAHF-NEXT: popq %rax
211 ; 64-FAST-RA-SAHF-NEXT: movq %rax, %rdi
212 ; 64-FAST-RA-SAHF-NEXT: callq bar
213 ; 64-FAST-RA-SAHF-NEXT: movq %rbx, %rax
214 ; 64-FAST-RA-SAHF-NEXT: addb $127, %al
215 ; 64-FAST-RA-SAHF-NEXT: sahf
216 ; 64-FAST-RA-SAHF-NEXT: jne .LBB0_3
217 ; 64-FAST-RA-SAHF-NEXT: # %bb.1: # %t
218 ; 64-FAST-RA-SAHF-NEXT: movl $42, %eax
219 ; 64-FAST-RA-SAHF-NEXT: jmp .LBB0_2
220 ; 64-FAST-RA-SAHF-NEXT: .LBB0_3: # %f
221 ; 64-FAST-RA-SAHF-NEXT: xorl %eax, %eax
222 ; 64-FAST-RA-SAHF-NEXT: .LBB0_2: # %t
223 ; 64-FAST-RA-SAHF-NEXT: addq $8, %rsp
224 ; 64-FAST-RA-SAHF-NEXT: popq %rbx
225 ; 64-FAST-RA-SAHF-NEXT: popq %rbp
226 ; 64-FAST-RA-SAHF-NEXT: retq
227 entry:
97228 %cx = cmpxchg i64* %foo, i64 %bar, i64 %baz seq_cst seq_cst
98229 %v = extractvalue { i64, i1 } %cx, 0
99230 %p = extractvalue { i64, i1 } %cx, 1
108239 }
109240
110241 ; Interesting in producing a clobber without any function calls.
111 define i32 @test_control_flow(i32* %p, i32 %i, i32 %j) {
112 ; i386-LABEL: test_control_flow:
113 ; i386: cmpxchg
114 ; i386-NEXT: jne
115
116 ; i386f-LABEL: test_control_flow:
117 ; i386f: cmpxchg
118 ; i386f-NEXT: jne
119
120 ; x8664-LABEL: test_control_flow:
121 ; x8664: cmpxchg
122 ; x8664-NEXT: jne
123
124 ; x8664-sahf-LABEL: test_control_flow:
125 ; x8664-sahf: cmpxchg
126 ; x8664-sahf-NEXT: jne
127
242 define i32 @test_control_flow(i32* %p, i32 %i, i32 %j) nounwind {
243 ; 32-ALL-LABEL: test_control_flow:
244 ; 32-ALL: # %bb.0: # %entry
245 ; 32-ALL-NEXT: movl {{[0-9]+}}(%esp), %eax
246 ; 32-ALL-NEXT: cmpl {{[0-9]+}}(%esp), %eax
247 ; 32-ALL-NEXT: jle .LBB1_6
248 ; 32-ALL-NEXT: # %bb.1: # %loop_start
249 ; 32-ALL-NEXT: movl {{[0-9]+}}(%esp), %ecx
250 ; 32-ALL-NEXT: .p2align 4, 0x90
251 ; 32-ALL-NEXT: .LBB1_2: # %while.condthread-pre-split.i
252 ; 32-ALL-NEXT: # =>This Loop Header: Depth=1
253 ; 32-ALL-NEXT: # Child Loop BB1_3 Depth 2
254 ; 32-ALL-NEXT: movl (%ecx), %edx
255 ; 32-ALL-NEXT: .p2align 4, 0x90
256 ; 32-ALL-NEXT: .LBB1_3: # %while.cond.i
257 ; 32-ALL-NEXT: # Parent Loop BB1_2 Depth=1
258 ; 32-ALL-NEXT: # => This Inner Loop Header: Depth=2
259 ; 32-ALL-NEXT: movl %edx, %eax
260 ; 32-ALL-NEXT: xorl %edx, %edx
261 ; 32-ALL-NEXT: testl %eax, %eax
262 ; 32-ALL-NEXT: je .LBB1_3
263 ; 32-ALL-NEXT: # %bb.4: # %while.body.i
264 ; 32-ALL-NEXT: # in Loop: Header=BB1_2 Depth=1
265 ; 32-ALL-NEXT: lock cmpxchgl %eax, (%ecx)
266 ; 32-ALL-NEXT: jne .LBB1_2
267 ; 32-ALL-NEXT: # %bb.5:
268 ; 32-ALL-NEXT: xorl %eax, %eax
269 ; 32-ALL-NEXT: .LBB1_6: # %cond.end
270 ; 32-ALL-NEXT: retl
271 ;
272 ; 64-ALL-LABEL: test_control_flow:
273 ; 64-ALL: # %bb.0: # %entry
274 ; 64-ALL-NEXT: cmpl %edx, %esi
275 ; 64-ALL-NEXT: jle .LBB1_5
276 ; 64-ALL-NEXT: .p2align 4, 0x90
277 ; 64-ALL-NEXT: .LBB1_1: # %while.condthread-pre-split.i
278 ; 64-ALL-NEXT: # =>This Loop Header: Depth=1
279 ; 64-ALL-NEXT: # Child Loop BB1_2 Depth 2
280 ; 64-ALL-NEXT: movl (%rdi), %ecx
281 ; 64-ALL-NEXT: .p2align 4, 0x90
282 ; 64-ALL-NEXT: .LBB1_2: # %while.cond.i
283 ; 64-ALL-NEXT: # Parent Loop BB1_1 Depth=1
284 ; 64-ALL-NEXT: # => This Inner Loop Header: Depth=2
285 ; 64-ALL-NEXT: movl %ecx, %eax
286 ; 64-ALL-NEXT: xorl %ecx, %ecx
287 ; 64-ALL-NEXT: testl %eax, %eax
288 ; 64-ALL-NEXT: je .LBB1_2
289 ; 64-ALL-NEXT: # %bb.3: # %while.body.i
290 ; 64-ALL-NEXT: # in Loop: Header=BB1_1 Depth=1
291 ; 64-ALL-NEXT: lock cmpxchgl %eax, (%rdi)
292 ; 64-ALL-NEXT: jne .LBB1_1
293 ; 64-ALL-NEXT: # %bb.4:
294 ; 64-ALL-NEXT: xorl %esi, %esi
295 ; 64-ALL-NEXT: .LBB1_5: # %cond.end
296 ; 64-ALL-NEXT: movl %esi, %eax
297 ; 64-ALL-NEXT: retq
128298 entry:
129299 %cmp = icmp sgt i32 %i, %j
130300 br i1 %cmp, label %loop_start, label %cond.end
157327
158328 ; This one is an interesting case because CMOV doesn't have a chain
159329 ; operand. Naive attempts to limit cmpxchg EFLAGS use are likely to fail here.
160 define i32 @test_feed_cmov(i32* %addr, i32 %desired, i32 %new) {
161 ; i386-LABEL: test_feed_cmov:
162 ; i386: cmpxchgl
163 ; i386-NEXT: seto %al
164 ; i386-NEXT: lahf
165 ; i386-NEXT: movl %eax, [[FLAGS:%.*]]
166 ; i386-NEXT: calll foo
167 ; i386-NEXT: pushl %eax
168 ; i386-NEXT: movl [[FLAGS]], %eax
169 ; i386-NEXT: addb $127, %al
170 ; i386-NEXT: sahf
171 ; i386-NEXT: popl %eax
172
173 ; i386f-LABEL: test_feed_cmov:
174 ; i386f: cmpxchgl
175 ; i386f-NEXT: seto %al
176 ; i386f-NEXT: lahf
177 ; i386f-NEXT: movl %eax, [[FLAGS:%.*]]
178 ; i386f-NEXT: calll foo
179 ; i386f-NEXT: pushl %eax
180 ; i386f-NEXT: movl [[FLAGS]], %eax
181 ; i386f-NEXT: addb $127, %al
182 ; i386f-NEXT: sahf
183 ; i386f-NEXT: popl %eax
184
185 ; x8664-LABEL: test_feed_cmov:
186 ; x8664: cmpxchg
187 ; x8664: pushfq
188 ; x8664-NEXT: popq [[FLAGS:%.*]]
189 ; x8664-NEXT: callq foo
190 ; x8664-NEXT: pushq [[FLAGS]]
191 ; x8664-NEXT: popfq
192
193 ; x8664-sahf-LABEL: test_feed_cmov:
194 ; x8664-sahf: cmpxchgl
195 ; RAX is dead, do not push or pop it.
196 ; x8664-sahf-NEXT: seto %al
197 ; x8664-sahf-NEXT: lahf
198 ; x8664-sahf-NEXT: movq %rax, [[FLAGS:%.*]]
199 ; x8664-sahf-NEXT: callq foo
200 ; x8664-sahf-NEXT: pushq %rax
201 ; x8664-sahf-NEXT: movq [[FLAGS]], %rax
202 ; x8664-sahf-NEXT: addb $127, %al
203 ; x8664-sahf-NEXT: sahf
204 ; x8664-sahf-NEXT: popq %rax
205
330 define i32 @test_feed_cmov(i32* %addr, i32 %desired, i32 %new) nounwind {
331 ; 32-GOOD-RA-LABEL: test_feed_cmov:
332 ; 32-GOOD-RA: # %bb.0: # %entry
333 ; 32-GOOD-RA-NEXT: pushl %ebp
334 ; 32-GOOD-RA-NEXT: movl %esp, %ebp
335 ; 32-GOOD-RA-NEXT: pushl %edi
336 ; 32-GOOD-RA-NEXT: pushl %esi
337 ; 32-GOOD-RA-NEXT: movl 12(%ebp), %eax
338 ; 32-GOOD-RA-NEXT: movl 16(%ebp), %esi
339 ; 32-GOOD-RA-NEXT: movl 8(%ebp), %ecx
340 ; 32-GOOD-RA-NEXT: lock cmpxchgl %esi, (%ecx)
341 ; 32-GOOD-RA-NEXT: seto %al
342 ; 32-GOOD-RA-NEXT: lahf
343 ; 32-GOOD-RA-NEXT: movl %eax, %edi
344 ; 32-GOOD-RA-NEXT: calll foo
345 ; 32-GOOD-RA-NEXT: pushl %eax
346 ; 32-GOOD-RA-NEXT: movl %edi, %eax
347 ; 32-GOOD-RA-NEXT: addb $127, %al
348 ; 32-GOOD-RA-NEXT: sahf
349 ; 32-GOOD-RA-NEXT: popl %eax
350 ; 32-GOOD-RA-NEXT: je .LBB2_2
351 ; 32-GOOD-RA-NEXT: # %bb.1: # %entry
352 ; 32-GOOD-RA-NEXT: movl %eax, %esi
353 ; 32-GOOD-RA-NEXT: .LBB2_2: # %entry
354 ; 32-GOOD-RA-NEXT: movl %esi, %eax
355 ; 32-GOOD-RA-NEXT: popl %esi
356 ; 32-GOOD-RA-NEXT: popl %edi
357 ; 32-GOOD-RA-NEXT: popl %ebp
358 ; 32-GOOD-RA-NEXT: retl
359 ;
360 ; 32-FAST-RA-LABEL: test_feed_cmov:
361 ; 32-FAST-RA: # %bb.0: # %entry
362 ; 32-FAST-RA-NEXT: pushl %ebp
363 ; 32-FAST-RA-NEXT: movl %esp, %ebp
364 ; 32-FAST-RA-NEXT: pushl %edi
365 ; 32-FAST-RA-NEXT: pushl %esi
366 ; 32-FAST-RA-NEXT: movl 8(%ebp), %ecx
367 ; 32-FAST-RA-NEXT: movl 16(%ebp), %esi
368 ; 32-FAST-RA-NEXT: movl 12(%ebp), %eax
369 ; 32-FAST-RA-NEXT: lock cmpxchgl %esi, (%ecx)
370 ; 32-FAST-RA-NEXT: seto %al
371 ; 32-FAST-RA-NEXT: lahf
372 ; 32-FAST-RA-NEXT: movl %eax, %edi
373 ; 32-FAST-RA-NEXT: calll foo
374 ; 32-FAST-RA-NEXT: pushl %eax
375 ; 32-FAST-RA-NEXT: movl %edi, %eax
376 ; 32-FAST-RA-NEXT: addb $127, %al
377 ; 32-FAST-RA-NEXT: sahf
378 ; 32-FAST-RA-NEXT: popl %eax
379 ; 32-FAST-RA-NEXT: je .LBB2_2
380 ; 32-FAST-RA-NEXT: # %bb.1: # %entry
381 ; 32-FAST-RA-NEXT: movl %eax, %esi
382 ; 32-FAST-RA-NEXT: .LBB2_2: # %entry
383 ; 32-FAST-RA-NEXT: movl %esi, %eax
384 ; 32-FAST-RA-NEXT: popl %esi
385 ; 32-FAST-RA-NEXT: popl %edi
386 ; 32-FAST-RA-NEXT: popl %ebp
387 ; 32-FAST-RA-NEXT: retl
388 ;
389 ; 64-GOOD-RA-LABEL: test_feed_cmov:
390 ; 64-GOOD-RA: # %bb.0: # %entry
391 ; 64-GOOD-RA-NEXT: pushq %rbp
392 ; 64-GOOD-RA-NEXT: movq %rsp, %rbp
393 ; 64-GOOD-RA-NEXT: pushq %r14
394 ; 64-GOOD-RA-NEXT: pushq %rbx
395 ; 64-GOOD-RA-NEXT: movl %edx, %ebx
396 ; 64-GOOD-RA-NEXT: movl %esi, %eax
397 ; 64-GOOD-RA-NEXT: lock cmpxchgl %ebx, (%rdi)
398 ; 64-GOOD-RA-NEXT: pushfq
399 ; 64-GOOD-RA-NEXT: popq %r14
400 ; 64-GOOD-RA-NEXT: callq foo
401 ; 64-GOOD-RA-NEXT: pushq %r14
402 ; 64-GOOD-RA-NEXT: popfq
403 ; 64-GOOD-RA-NEXT: cmovel %ebx, %eax
404 ; 64-GOOD-RA-NEXT: popq %rbx
405 ; 64-GOOD-RA-NEXT: popq %r14
406 ; 64-GOOD-RA-NEXT: popq %rbp
407 ; 64-GOOD-RA-NEXT: retq
408 ;
409 ; 64-FAST-RA-LABEL: test_feed_cmov:
410 ; 64-FAST-RA: # %bb.0: # %entry
411 ; 64-FAST-RA-NEXT: pushq %rbp
412 ; 64-FAST-RA-NEXT: movq %rsp, %rbp
413 ; 64-FAST-RA-NEXT: pushq %r14
414 ; 64-FAST-RA-NEXT: pushq %rbx
415 ; 64-FAST-RA-NEXT: movl %edx, %ebx
416 ; 64-FAST-RA-NEXT: movl %esi, %eax
417 ; 64-FAST-RA-NEXT: lock cmpxchgl %ebx, (%rdi)
418 ; 64-FAST-RA-NEXT: pushfq
419 ; 64-FAST-RA-NEXT: popq %r14
420 ; 64-FAST-RA-NEXT: callq foo
421 ; 64-FAST-RA-NEXT: pushq %r14
422 ; 64-FAST-RA-NEXT: popfq
423 ; 64-FAST-RA-NEXT: cmovel %ebx, %eax
424 ; 64-FAST-RA-NEXT: popq %rbx
425 ; 64-FAST-RA-NEXT: popq %r14
426 ; 64-FAST-RA-NEXT: popq %rbp
427 ; 64-FAST-RA-NEXT: retq
428 ;
429 ; 64-GOOD-RA-SAHF-LABEL: test_feed_cmov:
430 ; 64-GOOD-RA-SAHF: # %bb.0: # %entry
431 ; 64-GOOD-RA-SAHF-NEXT: pushq %rbp
432 ; 64-GOOD-RA-SAHF-NEXT: movq %rsp, %rbp
433 ; 64-GOOD-RA-SAHF-NEXT: pushq %r14
434 ; 64-GOOD-RA-SAHF-NEXT: pushq %rbx
435 ; 64-GOOD-RA-SAHF-NEXT: movl %edx, %ebx
436 ; 64-GOOD-RA-SAHF-NEXT: movl %esi, %eax
437 ; 64-GOOD-RA-SAHF-NEXT: lock cmpxchgl %ebx, (%rdi)
438 ; 64-GOOD-RA-SAHF-NEXT: seto %al
439 ; 64-GOOD-RA-SAHF-NEXT: lahf
440 ; 64-GOOD-RA-SAHF-NEXT: movq %rax, %r14
441 ; 64-GOOD-RA-SAHF-NEXT: callq foo
442 ; 64-GOOD-RA-SAHF-NEXT: pushq %rax
443 ; 64-GOOD-RA-SAHF-NEXT: movq %r14, %rax
444 ; 64-GOOD-RA-SAHF-NEXT: addb $127, %al
445 ; 64-GOOD-RA-SAHF-NEXT: sahf
446 ; 64-GOOD-RA-SAHF-NEXT: popq %rax
447 ; 64-GOOD-RA-SAHF-NEXT: cmovel %ebx, %eax
448 ; 64-GOOD-RA-SAHF-NEXT: popq %rbx
449 ; 64-GOOD-RA-SAHF-NEXT: popq %r14
450 ; 64-GOOD-RA-SAHF-NEXT: popq %rbp
451 ; 64-GOOD-RA-SAHF-NEXT: retq
452 ;
453 ; 64-FAST-RA-SAHF-LABEL: test_feed_cmov:
454 ; 64-FAST-RA-SAHF: # %bb.0: # %entry
455 ; 64-FAST-RA-SAHF-NEXT: pushq %rbp
456 ; 64-FAST-RA-SAHF-NEXT: movq %rsp, %rbp
457 ; 64-FAST-RA-SAHF-NEXT: pushq %r14
458 ; 64-FAST-RA-SAHF-NEXT: pushq %rbx
459 ; 64-FAST-RA-SAHF-NEXT: movl %edx, %ebx
460 ; 64-FAST-RA-SAHF-NEXT: movl %esi, %eax
461 ; 64-FAST-RA-SAHF-NEXT: lock cmpxchgl %ebx, (%rdi)
462 ; 64-FAST-RA-SAHF-NEXT: seto %al
463 ; 64-FAST-RA-SAHF-NEXT: lahf
464 ; 64-FAST-RA-SAHF-NEXT: movq %rax, %r14
465 ; 64-FAST-RA-SAHF-NEXT: callq foo
466 ; 64-FAST-RA-SAHF-NEXT: pushq %rax
467 ; 64-FAST-RA-SAHF-NEXT: movq %r14, %rax
468 ; 64-FAST-RA-SAHF-NEXT: addb $127, %al
469 ; 64-FAST-RA-SAHF-NEXT: sahf
470 ; 64-FAST-RA-SAHF-NEXT: popq %rax
471 ; 64-FAST-RA-SAHF-NEXT: cmovel %ebx, %eax
472 ; 64-FAST-RA-SAHF-NEXT: popq %rbx
473 ; 64-FAST-RA-SAHF-NEXT: popq %r14
474 ; 64-FAST-RA-SAHF-NEXT: popq %rbp
475 ; 64-FAST-RA-SAHF-NEXT: retq
476 entry:
206477 %res = cmpxchg i32* %addr, i32 %desired, i32 %new seq_cst seq_cst
207478 %success = extractvalue { i32, i1 } %res, 1
208479