1 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 ; RUN: llc -mtriple=amdgcn-mesa-mesa3d -mcpu=gfx900 -verify-machineinstrs -stop-after=si-pre-emit-peephole -o - %s | FileCheck -check-prefix=GCN %s
3 ; If the block containing the SI_RETURN_TO_EPILOG is not the last block, insert an empty block at the end and
4 ; insert an unconditional jump there.
5 define amdgpu_ps float @simple_test_return_to_epilog(float %a) #0 {
6 ; GCN-LABEL: name: simple_test_return_to_epilog
9 ; GCN: SI_RETURN_TO_EPILOG killed $vgpr0
14 define amdgpu_ps float @test_return_to_epilog_into_end_block(i32 inreg %a, float %b) #0 {
15 ; GCN-LABEL: name: test_return_to_epilog_into_end_block
17 ; GCN: successors: %bb.1(0x80000000), %bb.2(0x00000000)
18 ; GCN: liveins: $sgpr2, $vgpr0
19 ; GCN: S_CMP_LT_I32 killed renamable $sgpr2, 1, implicit-def $scc
20 ; GCN: S_CBRANCH_SCC1 %bb.2, implicit killed $scc
22 ; GCN: successors: %bb.3(0x80000000)
23 ; GCN: liveins: $vgpr0
27 ; GCN: renamable $vgpr0 = V_MOV_B32_e32 0, implicit $exec
28 ; GCN: GLOBAL_STORE_DWORD undef renamable $vgpr0_vgpr1, killed renamable $vgpr0, 0, 0, implicit $exec :: (volatile store (s32) into `ptr addrspace(1) undef`, addrspace 1)
32 %cc = icmp sgt i32 %a, 0
33 br i1 %cc, label %if, label %else
36 else: ; preds = %entry
37 store volatile i32 0, ptr addrspace(1) undef
41 define amdgpu_ps float @test_unify_return_to_epilog_into_end_block(i32 inreg %a, i32 inreg %b, float %c, float %d) #0 {
42 ; GCN-LABEL: name: test_unify_return_to_epilog_into_end_block
44 ; GCN: successors: %bb.1(0x50000000), %bb.2(0x30000000)
45 ; GCN: liveins: $sgpr2, $sgpr3, $vgpr0, $vgpr1
46 ; GCN: S_CMP_LT_I32 killed renamable $sgpr2, 1, implicit-def $scc
47 ; GCN: S_CBRANCH_SCC1 %bb.2, implicit killed $scc
49 ; GCN: successors: %bb.5(0x80000000)
50 ; GCN: liveins: $vgpr0
52 ; GCN: bb.2.else.if.cond:
53 ; GCN: successors: %bb.3(0x80000000), %bb.4(0x00000000)
54 ; GCN: liveins: $sgpr3, $vgpr1
55 ; GCN: S_CMP_LT_I32 killed renamable $sgpr3, 1, implicit-def $scc
56 ; GCN: S_CBRANCH_SCC1 %bb.4, implicit killed $scc
58 ; GCN: successors: %bb.5(0x80000000)
59 ; GCN: liveins: $vgpr1
60 ; GCN: $vgpr0 = V_MOV_B32_e32 killed $vgpr1, implicit $exec, implicit $exec
64 ; GCN: renamable $vgpr0 = V_MOV_B32_e32 0, implicit $exec
65 ; GCN: GLOBAL_STORE_DWORD undef renamable $vgpr0_vgpr1, killed renamable $vgpr0, 0, 0, implicit $exec :: (volatile store (s32) into `ptr addrspace(1) undef`, addrspace 1)
69 %cc = icmp sgt i32 %a, 0
70 br i1 %cc, label %if, label %else.if.cond
73 else.if.cond: ; preds = %entry
74 %cc1 = icmp sgt i32 %b, 0
75 br i1 %cc1, label %else.if, label %else
76 else.if: ; preds = %else.if.cond
78 else: ; preds = %else.if.cond
79 store volatile i32 0, ptr addrspace(1) undef
83 define amdgpu_ps { <4 x float> } @test_return_to_epilog_with_optimized_kill(float %val) #0 {
84 ; GCN-LABEL: name: test_return_to_epilog_with_optimized_kill
85 ; GCN: bb.0 (%ir-block.0):
86 ; GCN: successors: %bb.3(0x40000000), %bb.1(0x40000000)
87 ; GCN: liveins: $vgpr0
88 ; GCN: renamable $vgpr1 = nofpexcept V_RCP_F32_e32 $vgpr0, implicit $mode, implicit $exec
89 ; GCN: $sgpr0_sgpr1 = S_MOV_B64 $exec
90 ; GCN: nofpexcept V_CMP_NGT_F32_e32 0, killed $vgpr1, implicit-def $vcc, implicit $mode, implicit $exec
91 ; GCN: $sgpr2_sgpr3 = S_AND_SAVEEXEC_B64 killed $vcc, implicit-def $exec, implicit-def $scc, implicit $exec
92 ; GCN: renamable $sgpr2_sgpr3 = S_XOR_B64 $exec, killed renamable $sgpr2_sgpr3, implicit-def dead $scc
93 ; GCN: S_CBRANCH_EXECNZ %bb.3, implicit $exec
95 ; GCN: successors: %bb.6(0x40000000), %bb.2(0x40000000)
96 ; GCN: liveins: $sgpr0_sgpr1, $sgpr2_sgpr3
97 ; GCN: $sgpr2_sgpr3 = S_ANDN2_SAVEEXEC_B64 killed $sgpr2_sgpr3, implicit-def $exec, implicit-def $scc, implicit $exec
98 ; GCN: S_CBRANCH_EXECNZ %bb.6, implicit $exec
100 ; GCN: successors: %bb.9(0x80000000)
101 ; GCN: liveins: $sgpr2_sgpr3
102 ; GCN: $exec = S_OR_B64 $exec, killed renamable $sgpr2_sgpr3, implicit-def $scc
103 ; GCN: S_BRANCH %bb.9
104 ; GCN: bb.3.flow.preheader:
105 ; GCN: successors: %bb.4(0x80000000)
106 ; GCN: liveins: $vgpr0, $sgpr0_sgpr1, $sgpr2_sgpr3
107 ; GCN: nofpexcept V_CMP_NGT_F32_e32 0, killed $vgpr0, implicit-def $vcc, implicit $mode, implicit $exec
108 ; GCN: renamable $sgpr4_sgpr5 = S_MOV_B64 0
110 ; GCN: successors: %bb.5(0x04000000), %bb.4(0x7c000000)
111 ; GCN: liveins: $vcc, $sgpr0_sgpr1, $sgpr2_sgpr3, $sgpr4_sgpr5
112 ; GCN: renamable $sgpr6_sgpr7 = S_AND_B64 $exec, renamable $vcc, implicit-def $scc
113 ; GCN: renamable $sgpr4_sgpr5 = S_OR_B64 killed renamable $sgpr6_sgpr7, killed renamable $sgpr4_sgpr5, implicit-def $scc
114 ; GCN: $exec = S_ANDN2_B64 $exec, renamable $sgpr4_sgpr5, implicit-def $scc
115 ; GCN: S_CBRANCH_EXECNZ %bb.4, implicit $exec
117 ; GCN: successors: %bb.6(0x40000000), %bb.2(0x40000000)
118 ; GCN: liveins: $sgpr0_sgpr1, $sgpr2_sgpr3, $sgpr4_sgpr5
119 ; GCN: $exec = S_OR_B64 $exec, killed renamable $sgpr4_sgpr5, implicit-def $scc
120 ; GCN: $sgpr2_sgpr3 = S_ANDN2_SAVEEXEC_B64 killed $sgpr2_sgpr3, implicit-def $exec, implicit-def $scc, implicit $exec
121 ; GCN: S_CBRANCH_EXECZ %bb.2, implicit $exec
123 ; GCN: successors: %bb.7(0x40000000), %bb.8(0x40000000)
124 ; GCN: liveins: $sgpr0_sgpr1, $sgpr2_sgpr3
125 ; GCN: dead renamable $sgpr0_sgpr1 = S_ANDN2_B64 killed renamable $sgpr0_sgpr1, $exec, implicit-def $scc
126 ; GCN: S_CBRANCH_SCC0 %bb.8, implicit $scc
128 ; GCN: successors: %bb.9(0x80000000)
129 ; GCN: liveins: $sgpr2_sgpr3, $scc
130 ; GCN: $exec = S_MOV_B64 0
131 ; GCN: $exec = S_OR_B64 $exec, killed renamable $sgpr2_sgpr3, implicit-def $scc
132 ; GCN: S_BRANCH %bb.9
134 ; GCN: $exec = S_MOV_B64 0
135 ; GCN: EXP_DONE 9, undef $vgpr0, undef $vgpr0, undef $vgpr0, undef $vgpr0, 1, 0, 0, implicit $exec
138 %.i0 = fdiv reassoc nnan nsz arcp contract afn float 1.000000e+00, %val
139 %cmp0 = fcmp olt float %.i0, 0.000000e+00
140 br i1 %cmp0, label %kill0, label %flow
142 kill0: ; preds = %entry
143 call void @llvm.amdgcn.kill(i1 false)
146 flow: ; preds = %entry
147 %cmp1 = fcmp olt float %val, 0.000000e+00
148 br i1 %cmp1, label %flow, label %end
150 kill1: ; preds = %flow
151 call void @llvm.amdgcn.kill(i1 false)
154 end: ; preds = %kill0, %kill1, %flow
155 ret { <4 x float> } undef
158 declare void @llvm.amdgcn.kill(i1) #0
160 attributes #0 = { nounwind }