1 ; RUN: llc -verify-machineinstrs -mtriple=i386-linux-gnu %s -o - | FileCheck %s -check-prefix=i386
2 ; RUN: llc -verify-machineinstrs -mtriple=i386-linux-gnu -pre-RA-sched=fast %s -o - | FileCheck %s -check-prefix=i386f
3 ; RUN: llc -verify-machineinstrs -mtriple=x86_64-linux-gnu %s -o - | FileCheck %s -check-prefix=x8664
4 ; RUN: llc -verify-machineinstrs -mtriple=x86_64-linux-gnu -pre-RA-sched=fast %s -o - | FileCheck %s -check-prefix=x8664
9 define i64 @test_intervening_call(i64* %foo, i64 %bar, i64 %baz) {
10 ; i386-LABEL: test_intervening_call:
12 ; i386-NEXT: pushl %eax
15 ; i386-NEXT: movl %eax, [[FLAGS:%.*]]
16 ; i386-NEXT: popl %eax
17 ; i386-NEXT: movl %edx, 4(%esp)
18 ; i386-NEXT: movl %eax, (%esp)
19 ; i386-NEXT: calll bar
20 ; i386-NEXT: movl [[FLAGS]], %eax
21 ; i386-NEXT: addb $127, %al
25 ; i386f-LABEL: test_intervening_call:
27 ; i386f-NEXT: movl %eax, (%esp)
28 ; i386f-NEXT: movl %edx, 4(%esp)
29 ; i386f-NEXT: seto %al
31 ; i386f-NEXT: movl %eax, [[FLAGS:%.*]]
32 ; i386f-NEXT: calll bar
33 ; i386f-NEXT: movl [[FLAGS]], %eax
34 ; i386f-NEXT: addb $127, %al
38 ; x8664-LABEL: test_intervening_call:
41 ; x8664-NEXT: seto %al
43 ; x8664-NEXT: movq %rax, [[FLAGS:%.*]]
44 ; x8664-NEXT: popq %rax
45 ; x8664-NEXT: movq %rax, %rdi
46 ; x8664-NEXT: callq bar
47 ; x8664-NEXT: movq [[FLAGS]], %rax
48 ; x8664-NEXT: addb $127, %al
52 %cx = cmpxchg i64* %foo, i64 %bar, i64 %baz seq_cst seq_cst
53 %v = extractvalue { i64, i1 } %cx, 0
54 %p = extractvalue { i64, i1 } %cx, 1
56 br i1 %p, label %t, label %f
65 ; Interesting in producing a clobber without any function calls.
66 define i32 @test_control_flow(i32* %p, i32 %i, i32 %j) {
67 ; i386-LABEL: test_control_flow:
71 ; i386f-LABEL: test_control_flow:
75 ; x8664-LABEL: test_control_flow:
80 %cmp = icmp sgt i32 %i, %j
81 br i1 %cmp, label %loop_start, label %cond.end
84 br label %while.condthread-pre-split.i
86 while.condthread-pre-split.i:
87 %.pr.i = load i32, i32* %p, align 4
88 br label %while.cond.i
91 %0 = phi i32 [ %.pr.i, %while.condthread-pre-split.i ], [ 0, %while.cond.i ]
92 %tobool.i = icmp eq i32 %0, 0
93 br i1 %tobool.i, label %while.cond.i, label %while.body.i
96 %.lcssa = phi i32 [ %0, %while.cond.i ]
97 %1 = cmpxchg i32* %p, i32 %.lcssa, i32 %.lcssa seq_cst seq_cst
98 %2 = extractvalue { i32, i1 } %1, 1
99 br i1 %2, label %cond.end.loopexit, label %while.condthread-pre-split.i
105 %cond = phi i32 [ %i, %entry ], [ 0, %cond.end.loopexit ]
109 ; This one is an interesting case because CMOV doesn't have a chain
110 ; operand. Naive attempts to limit cmpxchg EFLAGS use are likely to fail here.
111 define i32 @test_feed_cmov(i32* %addr, i32 %desired, i32 %new) {
112 ; i386-LABEL: test_feed_cmov:
114 ; i386-NEXT: seto %al
116 ; i386-NEXT: movl %eax, [[FLAGS:%.*]]
117 ; i386-NEXT: calll foo
118 ; i386-NEXT: pushl %eax
119 ; i386-NEXT: movl [[FLAGS]], %eax
120 ; i386-NEXT: addb $127, %al
122 ; i386-NEXT: popl %eax
124 ; i386f-LABEL: test_feed_cmov:
126 ; i386f-NEXT: seto %al
128 ; i386f-NEXT: movl %eax, [[FLAGS:%.*]]
129 ; i386f-NEXT: calll foo
130 ; i386f-NEXT: pushl %eax
131 ; i386f-NEXT: movl [[FLAGS]], %eax
132 ; i386f-NEXT: addb $127, %al
134 ; i386f-NEXT: popl %eax
136 ; x8664-LABEL: test_feed_cmov:
140 ; x8664-NEXT: movq %rax, [[FLAGS:%.*]]
141 ; x8664-NEXT: callq foo
142 ; x8664-NEXT: pushq %rax
143 ; x8664-NEXT: movq [[FLAGS]], %rax
144 ; x8664-NEXT: addb $127, %al
146 ; x8664-NEXT: popq %rax
148 %res = cmpxchg i32* %addr, i32 %desired, i32 %new seq_cst seq_cst
149 %success = extractvalue { i32, i1 } %res, 1
151 %rhs = call i32 @foo()
153 %ret = select i1 %success, i32 %new, i32 %rhs