1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes='cgscc(inline)' -S %s | FileCheck %s
4 define void @nonconvergent_callee() alwaysinline {
5 ; CHECK-LABEL: @nonconvergent_callee(
7 ; CHECK-NEXT: [[TOKEN:%.*]] = call token @llvm.experimental.convergence.anchor()
8 ; CHECK-NEXT: call void @f(i32 0) [ "convergencectrl"(token [[TOKEN]]) ]
12 %token = call token @llvm.experimental.convergence.anchor()
13 call void @f(i32 0) [ "convergencectrl"(token %token) ]
17 define void @convergent_callee(i32 %v) convergent alwaysinline {
18 ; CHECK-LABEL: @convergent_callee(
20 ; CHECK-NEXT: [[TOKEN:%.*]] = call token @llvm.experimental.convergence.entry()
21 ; CHECK-NEXT: call void @f(i32 [[V:%.*]]) [ "convergencectrl"(token [[TOKEN]]) ]
22 ; CHECK-NEXT: ret void
25 %token = call token @llvm.experimental.convergence.entry()
26 call void @f(i32 %v) [ "convergencectrl"(token %token) ]
30 define void @test_nonconvergent() {
31 ; CHECK-LABEL: @test_nonconvergent(
33 ; CHECK-NEXT: [[TOKEN_I:%.*]] = call token @llvm.experimental.convergence.anchor()
34 ; CHECK-NEXT: call void @f(i32 0) [ "convergencectrl"(token [[TOKEN_I]]) ]
35 ; CHECK-NEXT: ret void
38 call void @nonconvergent_callee()
42 define void @test_convergent_basic(i1 %cond) {
43 ; CHECK-LABEL: @test_convergent_basic(
45 ; CHECK-NEXT: [[TOKEN:%.*]] = call token @llvm.experimental.convergence.anchor()
46 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[THEN:%.*]], label [[END:%.*]]
48 ; CHECK-NEXT: call void @f(i32 0) [ "convergencectrl"(token [[TOKEN]]) ]
49 ; CHECK-NEXT: br label [[END]]
51 ; CHECK-NEXT: ret void
54 %token = call token @llvm.experimental.convergence.anchor()
55 br i1 %cond, label %then, label %end
58 call void @convergent_callee(i32 0) [ "convergencectrl"(token %token) ]
65 define void @test_convergent_no_token(i1 %cond) convergent {
66 ; CHECK-LABEL: @test_convergent_no_token(
68 ; CHECK-NEXT: call void @convergent_callee(i32 0)
69 ; CHECK-NEXT: ret void
72 call void @convergent_callee(i32 0)
76 define void @test_convergent_multiple() convergent {
77 ; CHECK-LABEL: @test_convergent_multiple(
79 ; CHECK-NEXT: [[TOKEN:%.*]] = call token @llvm.experimental.convergence.entry()
80 ; CHECK-NEXT: call void @f(i32 0) [ "convergencectrl"(token [[TOKEN]]) ]
81 ; CHECK-NEXT: call void @f(i32 1) [ "convergencectrl"(token [[TOKEN]]) ]
82 ; CHECK-NEXT: call void @f(i32 2) [ "convergencectrl"(token [[TOKEN]]) ]
83 ; CHECK-NEXT: ret void
86 %token = call token @llvm.experimental.convergence.entry()
87 call void @convergent_callee(i32 0) [ "convergencectrl"(token %token) ]
88 call void @convergent_callee(i32 1) [ "convergencectrl"(token %token) ]
89 call void @convergent_callee(i32 2) [ "convergencectrl"(token %token) ]
93 define void @test_convergent_loop(i1 %cond) {
94 ; CHECK-LABEL: @test_convergent_loop(
96 ; CHECK-NEXT: [[TOKEN:%.*]] = call token @llvm.experimental.convergence.anchor()
97 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[HDR:%.*]], label [[END:%.*]]
99 ; CHECK-NEXT: [[TOK_LOOP:%.*]] = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token [[TOKEN]]) ]
100 ; CHECK-NEXT: call void @f(i32 0) [ "convergencectrl"(token [[TOK_LOOP]]) ]
101 ; CHECK-NEXT: br i1 [[COND]], label [[HDR]], label [[END]]
103 ; CHECK-NEXT: ret void
106 %token = call token @llvm.experimental.convergence.anchor()
107 br i1 %cond, label %hdr, label %end
110 %tok.loop = call token @llvm.experimental.convergence.loop() [ "convergencectrl"(token %token) ]
111 call void @convergent_callee(i32 0) [ "convergencectrl"(token %tok.loop) ]
112 br i1 %cond, label %hdr, label %end
118 define void @make_indirect_call(ptr %f, i32 %x) convergent alwaysinline {
119 ; CHECK-LABEL: @make_indirect_call(
120 ; CHECK-NEXT: [[TOKEN:%.*]] = call token @llvm.experimental.convergence.entry()
121 ; CHECK-NEXT: call void [[F:%.*]](i32 [[X:%.*]]) #[[ATTR2:[0-9]+]] [ "convergencectrl"(token [[TOKEN]]) ]
122 ; CHECK-NEXT: ret void
124 %token = call token @llvm.experimental.convergence.entry()
125 call void %f(i32 %x) convergent [ "convergencectrl"(token %token) ]
129 define void @test_indirect_call() convergent {
130 ; CHECK-LABEL: @test_indirect_call(
132 ; CHECK-NEXT: [[TOKEN:%.*]] = call token @llvm.experimental.convergence.entry()
133 ; CHECK-NEXT: call void @f(i32 0) [ "convergencectrl"(token [[TOKEN]]) ]
134 ; CHECK-NEXT: ret void
137 %token = call token @llvm.experimental.convergence.entry()
138 call void @make_indirect_call(ptr @convergent_callee, i32 0) [ "convergencectrl"(token %token) ]
142 define void @recurse() convergent alwaysinline {
143 ; CHECK-LABEL: @recurse(
144 ; CHECK-NEXT: [[TOKEN:%.*]] = call token @llvm.experimental.convergence.entry()
145 ; CHECK-NEXT: call void @recurse() [ "convergencectrl"(token [[TOKEN]]) ]
146 ; CHECK-NEXT: ret void
148 %token = call token @llvm.experimental.convergence.entry()
149 call void @recurse() [ "convergencectrl"(token %token) ]
153 define void @test_recursive_call() convergent {
154 ; CHECK-LABEL: @test_recursive_call(
155 ; CHECK-NEXT: [[TOKEN:%.*]] = call token @llvm.experimental.convergence.entry()
156 ; CHECK-NEXT: call void @recurse() [ "convergencectrl"(token [[TOKEN]]) ]
157 ; CHECK-NEXT: ret void
159 %token = call token @llvm.experimental.convergence.entry()
160 call void @recurse() [ "convergencectrl"(token %token) ]
164 define i32 @outer_g(i32 %x) convergent alwaysinline {
165 ; CHECK-LABEL: @outer_g(
166 ; CHECK-NEXT: [[TOKEN:%.*]] = call token @llvm.experimental.convergence.entry()
167 ; CHECK-NEXT: [[Y:%.*]] = call i32 @g(i32 [[X:%.*]]) [ "convergencectrl"(token [[TOKEN]]) ]
168 ; CHECK-NEXT: ret i32 [[Y]]
170 %token = call token @llvm.experimental.convergence.entry()
171 %y = call i32 @g(i32 %x) [ "convergencectrl"(token %token) ]
175 define void @test_two_calls() convergent {
176 ; CHECK-LABEL: @test_two_calls(
177 ; CHECK-NEXT: [[TOKEN:%.*]] = call token @llvm.experimental.convergence.entry()
178 ; CHECK-NEXT: [[Y_I:%.*]] = call i32 @g(i32 23) [ "convergencectrl"(token [[TOKEN]]) ]
179 ; CHECK-NEXT: call void @f(i32 [[Y_I]]) [ "convergencectrl"(token [[TOKEN]]) ]
180 ; CHECK-NEXT: ret void
182 %token = call token @llvm.experimental.convergence.entry()
183 %x = call i32 @outer_g(i32 23) [ "convergencectrl"(token %token) ]
184 call void @convergent_callee(i32 %x) [ "convergencectrl"(token %token) ]
188 declare void @f(i32) convergent
189 declare i32 @g(i32) convergent
191 declare token @llvm.experimental.convergence.entry()
192 declare token @llvm.experimental.convergence.anchor()
193 declare token @llvm.experimental.convergence.loop()