[MachineScheduler] Fix physreg dependencies of ExitSU (#123541)
[llvm-project.git] / llvm / test / CodeGen / AMDGPU / ret_jump.ll
blob66a55d9eb128c656d30d6450e724bfda81833b57
1 ; RUN: llc -mtriple=amdgcn -mcpu=tahiti -verify-machineinstrs -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck -check-prefix=GCN %s
2 ; RUN: llc -mtriple=amdgcn -mcpu=tonga -verify-machineinstrs -simplifycfg-require-and-preserve-domtree=1 < %s | FileCheck -check-prefix=GCN %s
4 ; This should end with an no-op sequence of exec mask manipulations
5 ; Mask should be in original state after executed unreachable block
8 ; GCN-LABEL: {{^}}uniform_br_trivial_ret_divergent_br_trivial_unreachable:
9 ; GCN: s_cbranch_scc1 [[RET_BB:.LBB[0-9]+_[0-9]+]]
11 ; GCN-NEXT: ; %else
13 ; GCN: s_and_saveexec_b64 [[SAVE_EXEC:s\[[0-9]+:[0-9]+\]]], vcc
15 ; GCN: ; %bb.{{[0-9]+}}: ; %unreachable.bb
16 ; GCN-NEXT: ; divergent unreachable
18 ; GCN-NEXT: ; %bb.{{[0-9]+}}: ; %Flow
19 ; GCN-NEXT: s_or_b64 exec, exec
21 ; GCN-NEXT: [[RET_BB]]:
22 ; GCN-NEXT: ; return
23 ; GCN-NEXT: .Lfunc_end0
24 define amdgpu_ps <{ i32, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, float, float, float, float, float, float, float, float, float, float, float }> @uniform_br_trivial_ret_divergent_br_trivial_unreachable(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, ptr addrspace(4) inreg %arg3, float inreg %arg4, i32 inreg %arg5, <2 x i32> %arg6, <2 x i32> %arg7, <2 x i32> %arg8, <3 x i32> %arg9, <2 x i32> %arg10, <2 x i32> %arg11, <2 x i32> %arg12, float %arg13, float %arg14, float %arg15, float %arg16, i32 inreg %arg17, i32 %arg18, i32 %arg19, float %arg20, i32 %arg21) #0 {
25 entry:
26   %i.i = extractelement <2 x i32> %arg7, i32 0
27   %j.i = extractelement <2 x i32> %arg7, i32 1
28   %i.f.i = bitcast i32 %i.i to float
29   %j.f.i = bitcast i32 %j.i to float
30   %p1.i = call float @llvm.amdgcn.interp.p1(float %i.f.i, i32 1, i32 0, i32 %arg5) #2
31   %p2 = call float @llvm.amdgcn.interp.p2(float %p1.i, float %j.f.i, i32 1, i32 0, i32 %arg5) #2
32   %p87 = fmul float %p2, %p2
33   %p88 = fadd float %p87, %p87
34   %p93 = fadd float %p88, %p88
35   %p97 = fmul float %p93, %p93
36   %p102 = fsub float %p97, %p97
37   %p104 = fmul float %p102, %p102
38   %p106 = fadd float 0.000000e+00, %p104
39   %p108 = fadd float %p106, %p106
40   %uniform.cond = icmp slt i32 %arg17, 0
41   br i1 %uniform.cond, label %ret.bb, label %else
43 else:                                             ; preds = %main_body
44   %p124 = fmul float %p108, %p108
45   %p125 = fsub float %p124, %p124
46   %divergent.cond = fcmp olt float %p125, 0.000000e+00
47   br i1 %divergent.cond, label %ret.bb, label %unreachable.bb
49 unreachable.bb:                                           ; preds = %else
50   unreachable
52 ret.bb:                                          ; preds = %else, %main_body
53   ret <{ i32, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, float, float, float, float, float, float, float, float, float, float, float }> undef
56 ; GCN-LABEL: {{^}}uniform_br_nontrivial_ret_divergent_br_nontrivial_unreachable:
57 ; GCN: s_cbranch_vccz
59 ; GCN: ; %bb.{{[0-9]+}}: ; %Flow
60 ; GCN: s_cbranch_execnz [[RETURN:.LBB[0-9]+_[0-9]+]]
62 ; GCN: ; %UnifiedReturnBlock
63 ; GCN-NEXT: s_or_b64 exec, exec
64 ; GCN-NEXT: s_waitcnt
66 ; GCN: .LBB{{[0-9]+_[0-9]+}}: ; %else
67 ; GCN: s_and_saveexec_b64 [[SAVE_EXEC:s\[[0-9]+:[0-9]+\]]], vcc
69 ; GCN-NEXT:  ; %unreachable.bb
70 ; GCN: ds_write_b32
71 ; GCN: ; divergent unreachable
73 ; GCN: ; %ret.bb
74 ; GCN: store_dword
75 define amdgpu_ps <{ i32, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, float, float, float, float, float, float, float, float, float, float, float }> @uniform_br_nontrivial_ret_divergent_br_nontrivial_unreachable(ptr addrspace(4) inreg %arg, ptr addrspace(4) inreg %arg1, ptr addrspace(4) inreg %arg2, ptr addrspace(4) inreg %arg3, float inreg %arg4, i32 inreg %arg5, <2 x i32> %arg6, <2 x i32> %arg7, <2 x i32> %arg8, <3 x i32> %arg9, <2 x i32> %arg10, <2 x i32> %arg11, <2 x i32> %arg12, float %arg13, float %arg14, float %arg15, float %arg16, float %arg17, i32 inreg %arg18, i32 %arg19, float %arg20, i32 %arg21) #0 {
76 main_body:
77   %i.i = extractelement <2 x i32> %arg7, i32 0
78   %j.i = extractelement <2 x i32> %arg7, i32 1
79   %i.f.i = bitcast i32 %i.i to float
80   %j.f.i = bitcast i32 %j.i to float
81   %p1.i = call float @llvm.amdgcn.interp.p1(float %i.f.i, i32 1, i32 0, i32 %arg5) #2
82   %p2 = call float @llvm.amdgcn.interp.p2(float %p1.i, float %j.f.i, i32 1, i32 0, i32 %arg5) #2
83   %p87 = fmul float %p2, %p2
84   %p88 = fadd float %p87, %p87
85   %p93 = fadd float %p88, %p88
86   %p97 = fmul float %p93, %p93
87   %p102 = fsub float %p97, %p97
88   %p104 = fmul float %p102, %p102
89   %p106 = fadd float 0.000000e+00, %p104
90   %p108 = fadd float %p106, %p106
91   %uniform.cond = icmp slt i32 %arg18, 0
92   br i1 %uniform.cond, label %ret.bb, label %else
94 else:                                             ; preds = %main_body
95   %p124 = fmul float %p108, %p108
96   %p125 = fsub float %p124, %p124
97   %divergent.cond = fcmp olt float %p125, 0.000000e+00
98   br i1 %divergent.cond, label %ret.bb, label %unreachable.bb
100 unreachable.bb:                                           ; preds = %else
101   store volatile i32 8, ptr addrspace(3) undef
102   unreachable
104 ret.bb:                                          ; preds = %else, %main_body
105   store volatile i32 11, ptr addrspace(1) undef
106   ret <{ i32, i32, i32, i32, i32, i32, i32, i32, i32, float, float, float, float, float, float, float, float, float, float, float, float, float, float }> undef
109 ; Function Attrs: nounwind readnone
110 declare float @llvm.amdgcn.interp.p1(float, i32, i32, i32) #1
112 ; Function Attrs: nounwind readnone
113 declare float @llvm.amdgcn.interp.p2(float, float, i32, i32, i32) #1
115 ; Function Attrs: nounwind readnone
116 declare float @llvm.amdgcn.interp.mov(i32, i32, i32, i32) #1
118 ; Function Attrs: nounwind readnone
119 declare float @llvm.fabs.f32(float) #1
121 ; Function Attrs: nounwind readnone
122 declare float @llvm.sqrt.f32(float) #1
124 ; Function Attrs: nounwind readnone
125 declare float @llvm.floor.f32(float) #1
127 attributes #0 = { "InitialPSInputAddr"="36983" }
128 attributes #1 = { nounwind readnone }
129 attributes #2 = { nounwind }