11; RUN: llc --amdgpu-disable-structurizer -stop-after=amdgpu-isel -mtriple=amdgcn-- -mcpu=gfx900 -verify-machineinstrs -o - %s | FileCheck --check-prefixes=CHECK,ISEL %s
22; RUN: llc --amdgpu-disable-structurizer -stop-after=dead-mi-elimination -mtriple=amdgcn-- -mcpu=gfx900 -verify-machineinstrs -o - %s | FileCheck --check-prefixes=CHECK,DEADMI %s
3+ ; RUN: llc --amdgpu-disable-structurizer -global-isel -stop-after=irtranslator -mtriple=amdgcn-- -mcpu=gfx900 -verify-machineinstrs -o - %s | FileCheck %s --check-prefixes=CHECK,GISEL
34
45; CHECK-LABEL: name: basic_call
5- ; CHECK: [[TOKEN:%[0-9]+]]:sreg_64 = CONVERGENCECTRL_ENTRY
6+ ; CHECK: [[TOKEN:%[0-9]+]]{{[^ ]*}} = CONVERGENCECTRL_ENTRY
67; ISEL: {{.*}} SI_CALL_ISEL {{.*}}, @foo, [[TOKEN]], csr_amdgpu, {{.*}}
78; DEADMI: {{.*}} SI_CALL {{.*}}, @foo, csr_amdgpu, {{.*}}, implicit [[TOKEN]]
9+ ; GISEL: {{.*}} G_SI_CALL {{.*}}, @foo, csr_amdgpu, {{.*}}, implicit [[TOKEN]]
810define i32 @basic_call (i32 %src ) #0 {
911 %t = call token @llvm.experimental.convergence.entry ()
1012 %r = call i32 @foo (i32 %src ) [ "convergencectrl" (token %t ) ]
1113 ret i32 %r
1214}
1315
1416; CHECK-LABEL: name: basic_intrinsic
15- ; CHECK: [[TOKEN:%[0-9]+]]:sreg_64 = CONVERGENCECTRL_ANCHOR
17+ ; CHECK: [[TOKEN:%[0-9]+]]{{[^ ]*}} = CONVERGENCECTRL_ANCHOR
1618; ISEL: CONVERGENCECTRL_GLUE [[TOKEN]]
1719; DEADMI-NOT: CONVERGENCECTRL_GLUE
18- ; CHECK: {{.*}} = V_READFIRSTLANE_B32 {{.*}}, implicit [[TOKEN]]
20+ ; ISEL: {{.*}} = V_READFIRSTLANE_B32 {{.*}}, implicit [[TOKEN]]
21+ ; GISEL: {{.*}} = G_INTRINSIC_CONVERGENT intrinsic(@llvm.amdgcn.readfirstlane){{.*}}, implicit [[TOKEN]]
1922define i32 @basic_intrinsic (i32 %src ) #0 {
2023 %t = call token @llvm.experimental.convergence.anchor ()
2124 %r = call i32 @llvm.amdgcn.readfirstlane (i32 %src ) [ "convergencectrl" (token %t ) ]
@@ -30,12 +33,13 @@ define i32 @uncontrolled_call(i32 %src) #0 {
3033}
3134
3235; CHECK-LABEL: name: basic_branch
33- ; CHECK: bb.0 .entry:
34- ; CHECK: [[TOKEN:%[0-9]+]]:sreg_64 = CONVERGENCECTRL_ANCHOR
35- ; CHECK: bb.1 .then:
36+ ; CHECK: bb.[[#]] .entry:
37+ ; CHECK: [[TOKEN:%[0-9]+]]{{[^ ]*}} = CONVERGENCECTRL_ANCHOR
38+ ; CHECK: bb.[[#]] .then:
3639; ISEL: CONVERGENCECTRL_GLUE [[TOKEN]]
3740; DEADMI-NOT: CONVERGENCECTRL_GLUE
38- ; CHECK: {{.*}} = V_READFIRSTLANE_B32 {{.*}}, implicit [[TOKEN]]
41+ ; ISEL: {{.*}} = V_READFIRSTLANE_B32 {{.*}}, implicit [[TOKEN]]
42+ ; GISEL: {{.*}} = G_INTRINSIC_CONVERGENT intrinsic(@llvm.amdgcn.readfirstlane){{.*}}, implicit [[TOKEN]]
3943define i32 @basic_branch (i32 %src , i1 %cond ) #0 {
4044entry:
4145 %t = call token @llvm.experimental.convergence.anchor ()
@@ -52,12 +56,13 @@ else:
5256}
5357
5458; CHECK-LABEL: name: basic_loop
55- ; CHECK: [[TOKEN:%[0-9]+]]:sreg_64 = CONVERGENCECTRL_ANCHOR
56- ; CHECK: bb.1 .loop:
57- ; CHECK: [[LOOP:%[0-9]+]]:sreg_64 = CONVERGENCECTRL_LOOP [[TOKEN]]
59+ ; CHECK: [[TOKEN:%[0-9]+]]{{[^ ]*}} = CONVERGENCECTRL_ANCHOR
60+ ; CHECK: bb.[[#]] .loop:
61+ ; CHECK: [[LOOP:%[0-9]+]]{{[^ ]*}} = CONVERGENCECTRL_LOOP [[TOKEN]]
5862; ISEL: CONVERGENCECTRL_GLUE [[LOOP]]
5963; DEADMI-NOT: CONVERGENCECTRL_GLUE
60- ; CHECK: {{.*}} = V_READFIRSTLANE_B32 {{.*}}, implicit [[LOOP]]
64+ ; ISEL: {{.*}} = V_READFIRSTLANE_B32 {{.*}}, implicit [[LOOP]]
65+ ; GISEL: {{.*}} = G_INTRINSIC_CONVERGENT intrinsic(@llvm.amdgcn.readfirstlane){{.*}}, implicit [[LOOP]]
6166define i32 @basic_loop (i32 %src , i1 %cond ) #0 {
6267 %t1 = call token @llvm.experimental.convergence.anchor ()
6368 br label %loop
7176 ret i32 %r
7277}
7378
79+ ; CHECK-LABEL: name: nested
80+ ; CHECK: [[ENTRY:%[0-9]+]]{{[^ ]*}} = CONVERGENCECTRL_ENTRY
81+ ; CHECK: [[ANCHOR:%[0-9]+]]{{[^ ]*}} = CONVERGENCECTRL_ANCHOR
82+ ; ISEL: {{.*}} = V_READFIRSTLANE_B32 {{.*}}, implicit [[ANCHOR]]
83+ ; GISEL: {{.*}} = G_INTRINSIC_CONVERGENT intrinsic(@llvm.amdgcn.readfirstlane){{.*}}, implicit [[ANCHOR]]
84+ ; ISEL: {{.*}} = V_READFIRSTLANE_B32 {{.*}}, implicit [[ENTRY]]
85+ ; GISEL: {{.*}} = G_INTRINSIC_CONVERGENT intrinsic(@llvm.amdgcn.readfirstlane){{.*}}, implicit [[ENTRY]]
86+ define i32 @nested (i32 %src ) #0 {
87+ %t1 = call token @llvm.experimental.convergence.entry ()
88+ %t2 = call token @llvm.experimental.convergence.anchor ()
89+ %r2 = call i32 @llvm.amdgcn.readfirstlane (i32 %src ) [ "convergencectrl" (token %t2 ) ]
90+ %r1 = call i32 @llvm.amdgcn.readfirstlane (i32 %src ) [ "convergencectrl" (token %t1 ) ]
91+ %sum = add i32 %r1 , %r2
92+ ret i32 %sum
93+ }
94+
95+ ; COM: FIXME: Tokens on tail-call have not been implemented for SelectionDAG
96+ ; COM: yet; the corresponding checks have been commented out.
97+ ;
98+ ; CHECK-LABEL: name: tail_call_void_func_void
99+ ; GISEL: [[TOKEN:%[0-9]+]]{{[^ ]*}} = CONVERGENCECTRL_ENTRY
100+ ; COM: CHECK: [[TOKEN:%[0-9]+]]{{[^ ]*}} = CONVERGENCECTRL_ENTRY
101+ ; COM: ISEL: {{.*}} SI_CALL_ISEL {{.*}}, @external_void_func_void, [[TOKEN]], csr_amdgpu, {{.*}}
102+ ; COM: DEADMI: {{.*}} SI_CALL {{.*}}, @external_void_func_void, csr_amdgpu, {{.*}}, implicit [[TOKEN]]
103+ ; GISEL: {{.*}} SI_TCRETURN {{.*}}, @external_void_func_void, 0, csr_amdgpu, implicit [[TOKEN]]
104+ define void @tail_call_void_func_void () #0 {
105+ %t1 = call token @llvm.experimental.convergence.entry ()
106+ tail call void @external_void_func_void () [ "convergencectrl" (token %t1 ) ]
107+ ret void
108+ }
109+
110+ declare hidden void @external_void_func_void () #0
74111declare i32 @foo (i32 %x ) #0
75112
76113declare i32 @llvm.amdgcn.readfirstlane (i32 ) #0
0 commit comments