blob: e7a05d94cdc43c0ef7ba64fc698d6797f9a4e88f [file] [log] [blame]
Marek Olsaked2213e2016-03-14 15:57:14 +00001; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
3
Matt Arsenault9babdf42016-06-22 20:15:28 +00004; This should end with an no-op sequence of exec mask manipulations
5; Mask should be in original state after executed unreachable block
Marek Olsaked2213e2016-03-14 15:57:14 +00006
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +00007
8; GCN-LABEL: {{^}}uniform_br_trivial_ret_divergent_br_trivial_unreachable:
Matt Arsenault327188a2016-12-15 21:57:11 +00009; GCN: s_cbranch_scc1 [[RET_BB:BB[0-9]+_[0-9]+]]
Marek Olsaked2213e2016-03-14 15:57:14 +000010
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +000011; GCN-NEXT: ; %else
12
Matt Arsenault9babdf42016-06-22 20:15:28 +000013; GCN: s_and_saveexec_b64 [[SAVE_EXEC:s\[[0-9]+:[0-9]+\]]], vcc
14; GCN-NEXT: s_xor_b64 [[XOR_EXEC:s\[[0-9]+:[0-9]+\]]], exec, [[SAVE_EXEC]]
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +000015; GCN-NEXT: ; mask branch [[FLOW:BB[0-9]+_[0-9]+]]
Matt Arsenault9babdf42016-06-22 20:15:28 +000016
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +000017; GCN: BB{{[0-9]+_[0-9]+}}: ; %unreachable.bb
18; GCN-NEXT: ; divergent unreachable
Matt Arsenault9babdf42016-06-22 20:15:28 +000019
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +000020; GCN-NEXT: {{^}}[[FLOW]]: ; %Flow
21; GCN-NEXT: s_or_b64 exec, exec
22
23; GCN-NEXT: [[RET_BB]]:
24; GCN-NEXT: ; return
Matt Arsenault9babdf42016-06-22 20:15:28 +000025; GCN-NEXT: .Lfunc_end0
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +000026define 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([9 x <16 x i8>] addrspace(2)* byval %arg, [17 x <16 x i8>] addrspace(2)* byval %arg1, [17 x <8 x i32>] addrspace(2)* byval %arg2, i32 addrspace(2)* byval %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 {
27entry:
28 %i.i = extractelement <2 x i32> %arg7, i32 0
29 %j.i = extractelement <2 x i32> %arg7, i32 1
30 %i.f.i = bitcast i32 %i.i to float
31 %j.f.i = bitcast i32 %j.i to float
32 %p1.i = call float @llvm.amdgcn.interp.p1(float %i.f.i, i32 1, i32 0, i32 %arg5) #2
33 %p2.i = call float @llvm.amdgcn.interp.p2(float %p1.i, float %j.f.i, i32 1, i32 0, i32 %arg5) #2
34 %p87 = fmul float undef, %p2.i
35 %p88 = fadd float %p87, undef
36 %p93 = fadd float %p88, undef
37 %p97 = fmul float %p93, undef
38 %p102 = fsub float %p97, undef
39 %p104 = fmul float %p102, undef
40 %p106 = fadd float 0.000000e+00, %p104
41 %p108 = fadd float undef, %p106
42 %uniform.cond = icmp slt i32 %arg17, 0
43 br i1 %uniform.cond, label %ret.bb, label %else
44
45else: ; preds = %main_body
46 %p124 = fmul float %p108, %p108
47 %p125 = fsub float %p124, undef
48 %divergent.cond = fcmp olt float %p125, 0.000000e+00
49 br i1 %divergent.cond, label %ret.bb, label %unreachable.bb
50
51unreachable.bb: ; preds = %else
52 unreachable
53
54ret.bb: ; preds = %else, %main_body
55 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}
57
58; GCN-LABEL: {{^}}uniform_br_nontrivial_ret_divergent_br_nontrivial_unreachable:
Matt Arsenault44746522017-04-24 20:25:01 +000059; GCN: s_cbranch_vccnz [[RET_BB:BB[0-9]+_[0-9]+]]
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +000060
61; GCN: ; BB#{{[0-9]+}}: ; %else
62; GCN: s_and_saveexec_b64 [[SAVE_EXEC:s\[[0-9]+:[0-9]+\]]], vcc
63; GCN-NEXT: s_xor_b64 [[XOR_EXEC:s\[[0-9]+:[0-9]+\]]], exec, [[SAVE_EXEC]]
64; GCN-NEXT: ; mask branch [[FLOW1:BB[0-9]+_[0-9]+]]
65
66; GCN-NEXT: ; %unreachable.bb
67; GCN: ds_write_b32
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +000068; GCN: ; divergent unreachable
69
70; GCN: ; %ret.bb
71; GCN: store_dword
72
73; GCN: ; %UnifiedReturnBlock
74; GCN-NEXT: s_or_b64 exec, exec
Mark Searles70359ac2017-06-02 14:19:25 +000075; GCN-NEXT: s_waitcnt
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +000076; GCN-NEXT: ; return
77; GCN-NEXT: .Lfunc_end
78define 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([9 x <16 x i8>] addrspace(2)* byval %arg, [17 x <16 x i8>] addrspace(2)* byval %arg1, [17 x <8 x i32>] addrspace(2)* byval %arg2, i32 addrspace(2)* byval %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 {
Marek Olsaked2213e2016-03-14 15:57:14 +000079main_body:
Matt Arsenaultd2c8a332017-02-16 02:01:13 +000080 %i.i = extractelement <2 x i32> %arg7, i32 0
81 %j.i = extractelement <2 x i32> %arg7, i32 1
82 %i.f.i = bitcast i32 %i.i to float
83 %j.f.i = bitcast i32 %j.i to float
84 %p1.i = call float @llvm.amdgcn.interp.p1(float %i.f.i, i32 1, i32 0, i32 %arg5) #2
85 %p2.i = call float @llvm.amdgcn.interp.p2(float %p1.i, float %j.f.i, i32 1, i32 0, i32 %arg5) #2
86 %p87 = fmul float undef, %p2.i
Marek Olsaked2213e2016-03-14 15:57:14 +000087 %p88 = fadd float %p87, undef
88 %p93 = fadd float %p88, undef
89 %p97 = fmul float %p93, undef
90 %p102 = fsub float %p97, undef
91 %p104 = fmul float %p102, undef
92 %p106 = fadd float 0.000000e+00, %p104
93 %p108 = fadd float undef, %p106
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +000094 %uniform.cond = icmp slt i32 %arg18, 0
95 br i1 %uniform.cond, label %ret.bb, label %else
Marek Olsaked2213e2016-03-14 15:57:14 +000096
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +000097else: ; preds = %main_body
Marek Olsaked2213e2016-03-14 15:57:14 +000098 %p124 = fmul float %p108, %p108
99 %p125 = fsub float %p124, undef
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +0000100 %divergent.cond = fcmp olt float %p125, 0.000000e+00
101 br i1 %divergent.cond, label %ret.bb, label %unreachable.bb
Marek Olsaked2213e2016-03-14 15:57:14 +0000102
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +0000103unreachable.bb: ; preds = %else
104 store volatile i32 8, i32 addrspace(3)* undef
Marek Olsaked2213e2016-03-14 15:57:14 +0000105 unreachable
106
Matt Arsenaultb8f8dbc2017-03-24 19:52:05 +0000107ret.bb: ; preds = %else, %main_body
108 store volatile i32 11, i32 addrspace(1)* undef
Marek Olsaked2213e2016-03-14 15:57:14 +0000109 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
110}
111
112; Function Attrs: nounwind readnone
Matt Arsenaultd2c8a332017-02-16 02:01:13 +0000113declare float @llvm.amdgcn.interp.p1(float, i32, i32, i32) #1
Marek Olsaked2213e2016-03-14 15:57:14 +0000114
115; Function Attrs: nounwind readnone
Matt Arsenaultd2c8a332017-02-16 02:01:13 +0000116declare float @llvm.amdgcn.interp.p2(float, float, i32, i32, i32) #1
117
118; Function Attrs: nounwind readnone
119declare float @llvm.amdgcn.interp.mov(i32, i32, i32, i32) #1
120
121; Function Attrs: nounwind readnone
122declare float @llvm.SI.load.const(<16 x i8>, i32) #1
Marek Olsaked2213e2016-03-14 15:57:14 +0000123
124; Function Attrs: nounwind readnone
125declare float @llvm.fabs.f32(float) #1
126
127; Function Attrs: nounwind readnone
128declare float @llvm.sqrt.f32(float) #1
129
130; Function Attrs: nounwind readnone
131declare float @llvm.floor.f32(float) #1
132
Nicolai Haehnledf3a20c2016-04-06 19:40:20 +0000133attributes #0 = { "InitialPSInputAddr"="36983" }
Marek Olsaked2213e2016-03-14 15:57:14 +0000134attributes #1 = { nounwind readnone }
Matt Arsenaultd2c8a332017-02-16 02:01:13 +0000135attributes #2 = { nounwind }