1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2020 Valve Corporation
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21bf215546Sopenharmony_ci * IN THE SOFTWARE.
22bf215546Sopenharmony_ci *
23bf215546Sopenharmony_ci */
24bf215546Sopenharmony_ci#include "helpers.h"
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ciusing namespace aco;
27bf215546Sopenharmony_ci
28bf215546Sopenharmony_ciBEGIN_TEST(regalloc.subdword_alloc.reuse_16bit_operands)
29bf215546Sopenharmony_ci   /* Registers of operands should be "recycled" for the output. But if the
30bf215546Sopenharmony_ci    * input is smaller than the output, that's not generally possible. The
31bf215546Sopenharmony_ci    * first v_cvt_f32_f16 instruction below uses the upper 16 bits of v0
32bf215546Sopenharmony_ci    * while the lower 16 bits are still live, so the output must be stored in
33bf215546Sopenharmony_ci    * a register other than v0. For the second v_cvt_f32_f16, the original
34bf215546Sopenharmony_ci    * value stored in v0 is no longer used and hence it's safe to store the
35bf215546Sopenharmony_ci    * result in v0.
36bf215546Sopenharmony_ci    */
37bf215546Sopenharmony_ci
38bf215546Sopenharmony_ci   /* TODO: is this possible to do on GFX11? */
39bf215546Sopenharmony_ci   for (amd_gfx_level cc = GFX8; cc <= GFX10_3; cc = (amd_gfx_level)((unsigned)cc + 1)) {
40bf215546Sopenharmony_ci      for (bool pessimistic : { false, true }) {
41bf215546Sopenharmony_ci         const char* subvariant = pessimistic ? "/pessimistic" : "/optimistic";
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ci         //>> v1: %_:v[#a] = p_startpgm
44bf215546Sopenharmony_ci         if (!setup_cs("v1", (amd_gfx_level)cc, CHIP_UNKNOWN, subvariant))
45bf215546Sopenharmony_ci            return;
46bf215546Sopenharmony_ci
47bf215546Sopenharmony_ci         //! v2b: %_:v[#a][0:16], v2b: %res1:v[#a][16:32] = p_split_vector %_:v[#a]
48bf215546Sopenharmony_ci         Builder::Result tmp = bld.pseudo(aco_opcode::p_split_vector, bld.def(v2b), bld.def(v2b), inputs[0]);
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_ci         //! v1: %_:v[#b] = v_cvt_f32_f16 %_:v[#a][16:32] dst_sel:dword src0_sel:uword1
51bf215546Sopenharmony_ci         //! v1: %_:v[#a] = v_cvt_f32_f16 %_:v[#a][0:16]
52bf215546Sopenharmony_ci         //; success = (b != a)
53bf215546Sopenharmony_ci         auto result1 = bld.vop1(aco_opcode::v_cvt_f32_f16, bld.def(v1), tmp.def(1).getTemp());
54bf215546Sopenharmony_ci         auto result2 = bld.vop1(aco_opcode::v_cvt_f32_f16, bld.def(v1), tmp.def(0).getTemp());
55bf215546Sopenharmony_ci         writeout(0, result1);
56bf215546Sopenharmony_ci         writeout(1, result2);
57bf215546Sopenharmony_ci
58bf215546Sopenharmony_ci         finish_ra_test(ra_test_policy { pessimistic });
59bf215546Sopenharmony_ci      }
60bf215546Sopenharmony_ci   }
61bf215546Sopenharmony_ciEND_TEST
62bf215546Sopenharmony_ci
63bf215546Sopenharmony_ciBEGIN_TEST(regalloc.32bit_partial_write)
64bf215546Sopenharmony_ci   //>> v1: %_:v[0] = p_startpgm
65bf215546Sopenharmony_ci   if (!setup_cs("v1", GFX10))
66bf215546Sopenharmony_ci      return;
67bf215546Sopenharmony_ci
68bf215546Sopenharmony_ci   /* ensure high 16 bits are occupied */
69bf215546Sopenharmony_ci   //! v2b: %_:v[0][0:16], v2b: %_:v[0][16:32] = p_split_vector %_:v[0]
70bf215546Sopenharmony_ci   Temp hi = bld.pseudo(aco_opcode::p_split_vector, bld.def(v2b), bld.def(v2b), inputs[0]).def(1).getTemp();
71bf215546Sopenharmony_ci
72bf215546Sopenharmony_ci   /* This test checks if this instruction uses SDWA. */
73bf215546Sopenharmony_ci   //! v2b: %_:v[0][0:16] = v_not_b32 0 dst_sel:uword0 dst_preserve src0_sel:dword
74bf215546Sopenharmony_ci   Temp lo = bld.vop1(aco_opcode::v_not_b32, bld.def(v2b), Operand::zero());
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_ci   //! v1: %_:v[0] = p_create_vector %_:v[0][0:16], %_:v[0][16:32]
77bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_create_vector, bld.def(v1), lo, hi);
78bf215546Sopenharmony_ci
79bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy());
80bf215546Sopenharmony_ciEND_TEST
81bf215546Sopenharmony_ci
82bf215546Sopenharmony_ciBEGIN_TEST(regalloc.precolor.swap)
83bf215546Sopenharmony_ci   //>> s2: %op0:s[0-1] = p_startpgm
84bf215546Sopenharmony_ci   if (!setup_cs("s2", GFX10))
85bf215546Sopenharmony_ci      return;
86bf215546Sopenharmony_ci
87bf215546Sopenharmony_ci   program->dev.sgpr_limit = 4;
88bf215546Sopenharmony_ci
89bf215546Sopenharmony_ci   //! s2: %op1:s[2-3] = p_unit_test
90bf215546Sopenharmony_ci   Temp op1 = bld.pseudo(aco_opcode::p_unit_test, bld.def(s2));
91bf215546Sopenharmony_ci
92bf215546Sopenharmony_ci   //! s2: %op1_2:s[0-1], s2: %op0_2:s[2-3] = p_parallelcopy %op1:s[2-3], %op0:s[0-1]
93bf215546Sopenharmony_ci   //! p_unit_test %op0_2:s[2-3], %op1_2:s[0-1]
94bf215546Sopenharmony_ci   Operand op(inputs[0]);
95bf215546Sopenharmony_ci   op.setFixed(PhysReg(2));
96bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, op, op1);
97bf215546Sopenharmony_ci
98bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy());
99bf215546Sopenharmony_ciEND_TEST
100bf215546Sopenharmony_ci
101bf215546Sopenharmony_ciBEGIN_TEST(regalloc.precolor.blocking_vector)
102bf215546Sopenharmony_ci   //>> s2: %tmp0:s[0-1], s1: %tmp1:s[2] = p_startpgm
103bf215546Sopenharmony_ci   if (!setup_cs("s2 s1", GFX10))
104bf215546Sopenharmony_ci      return;
105bf215546Sopenharmony_ci
106bf215546Sopenharmony_ci   //! s2: %tmp0_2:s[2-3], s1: %tmp1_2:s[1] = p_parallelcopy %tmp0:s[0-1], %tmp1:s[2]
107bf215546Sopenharmony_ci   //! p_unit_test %tmp1_2:s[1]
108bf215546Sopenharmony_ci   Operand op(inputs[1]);
109bf215546Sopenharmony_ci   op.setFixed(PhysReg(1));
110bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, op);
111bf215546Sopenharmony_ci
112bf215546Sopenharmony_ci   //! p_unit_test %tmp0_2:s[2-3]
113bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, inputs[0]);
114bf215546Sopenharmony_ci
115bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy());
116bf215546Sopenharmony_ciEND_TEST
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_ciBEGIN_TEST(regalloc.precolor.vector.test)
119bf215546Sopenharmony_ci   //>> s2: %tmp0:s[0-1], s1: %tmp1:s[2], s1: %tmp2:s[3] = p_startpgm
120bf215546Sopenharmony_ci   if (!setup_cs("s2 s1 s1", GFX10))
121bf215546Sopenharmony_ci      return;
122bf215546Sopenharmony_ci
123bf215546Sopenharmony_ci   //! s1: %tmp2_2:s[0], s2: %tmp0_2:s[2-3] = p_parallelcopy %tmp2:s[3], %tmp0:s[0-1]
124bf215546Sopenharmony_ci   //! p_unit_test %tmp0_2:s[2-3]
125bf215546Sopenharmony_ci   Operand op(inputs[0]);
126bf215546Sopenharmony_ci   op.setFixed(PhysReg(2));
127bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, op);
128bf215546Sopenharmony_ci
129bf215546Sopenharmony_ci   //! p_unit_test %tmp2_2:s[0]
130bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, inputs[2]);
131bf215546Sopenharmony_ci
132bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy());
133bf215546Sopenharmony_ciEND_TEST
134bf215546Sopenharmony_ci
135bf215546Sopenharmony_ciBEGIN_TEST(regalloc.precolor.vector.collect)
136bf215546Sopenharmony_ci   //>> s2: %tmp0:s[0-1], s1: %tmp1:s[2], s1: %tmp2:s[3] = p_startpgm
137bf215546Sopenharmony_ci   if (!setup_cs("s2 s1 s1", GFX10))
138bf215546Sopenharmony_ci      return;
139bf215546Sopenharmony_ci
140bf215546Sopenharmony_ci   //! s1: %tmp1_2:s[0], s1: %tmp2_2:s[1], s2: %tmp0_2:s[2-3] = p_parallelcopy %tmp1:s[2], %tmp2:s[3], %tmp0:s[0-1]
141bf215546Sopenharmony_ci   //! p_unit_test %tmp0_2:s[2-3]
142bf215546Sopenharmony_ci   Operand op(inputs[0]);
143bf215546Sopenharmony_ci   op.setFixed(PhysReg(2));
144bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, op);
145bf215546Sopenharmony_ci
146bf215546Sopenharmony_ci   //! p_unit_test %tmp1_2:s[0], %tmp2_2:s[1]
147bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, inputs[1], inputs[2]);
148bf215546Sopenharmony_ci
149bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy());
150bf215546Sopenharmony_ciEND_TEST
151bf215546Sopenharmony_ci
152bf215546Sopenharmony_ciBEGIN_TEST(regalloc.scratch_sgpr.create_vector)
153bf215546Sopenharmony_ci   if (!setup_cs("v1 s1", GFX7))
154bf215546Sopenharmony_ci      return;
155bf215546Sopenharmony_ci
156bf215546Sopenharmony_ci   Temp tmp = bld.pseudo(aco_opcode::p_extract_vector, bld.def(v1b), inputs[0], Operand::zero());
157bf215546Sopenharmony_ci
158bf215546Sopenharmony_ci   //>> v3b: %0:v[0][0:24] = v_and_b32 0xffffff, %0:v[0][0:24]
159bf215546Sopenharmony_ci   //! s1: %0:s[1] = s_mov_b32 0x1000001
160bf215546Sopenharmony_ci   //! v1: %0:v[0] = v_mul_lo_u32 %0:s[1], %_:v[0][0:8]
161bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_create_vector, bld.def(v1), Operand(v3b), Operand(tmp));
162bf215546Sopenharmony_ci
163bf215546Sopenharmony_ci   //! p_unit_test %_:s[0]
164bf215546Sopenharmony_ci   //! s_endpgm
165bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, inputs[1]);
166bf215546Sopenharmony_ci
167bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy(), true);
168bf215546Sopenharmony_ciEND_TEST
169bf215546Sopenharmony_ci
170bf215546Sopenharmony_ciBEGIN_TEST(regalloc.scratch_sgpr.create_vector_sgpr_operand)
171bf215546Sopenharmony_ci   if (!setup_cs("v2 s1", GFX7))
172bf215546Sopenharmony_ci      return;
173bf215546Sopenharmony_ci
174bf215546Sopenharmony_ci   Temp tmp = bld.pseudo(aco_opcode::p_extract_vector, bld.def(v1b), inputs[0], Operand::c32(4u));
175bf215546Sopenharmony_ci
176bf215546Sopenharmony_ci   //>> v1: %0:v[0] = v_mov_b32 %_:s[0]
177bf215546Sopenharmony_ci   //! v3b: %0:v[1][0:24] = v_and_b32 0xffffff, %0:v[1][0:24]
178bf215546Sopenharmony_ci   //! s1: %0:s[1] = s_mov_b32 0x1000001
179bf215546Sopenharmony_ci   //! v1: %0:v[1] = v_mul_lo_u32 %0:s[1], %_:v[1][0:8]
180bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_create_vector, bld.def(v2), inputs[1], Operand(v3b), Operand(tmp));
181bf215546Sopenharmony_ci
182bf215546Sopenharmony_ci   //! p_unit_test %_:s[0]
183bf215546Sopenharmony_ci   //! s_endpgm
184bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, inputs[1]);
185bf215546Sopenharmony_ci
186bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy(), true);
187bf215546Sopenharmony_ciEND_TEST
188bf215546Sopenharmony_ci
189bf215546Sopenharmony_ciBEGIN_TEST(regalloc.linear_vgpr.live_range_split.fixed_def)
190bf215546Sopenharmony_ci   //>> p_startpgm
191bf215546Sopenharmony_ci   if (!setup_cs("", GFX10))
192bf215546Sopenharmony_ci      return;
193bf215546Sopenharmony_ci
194bf215546Sopenharmony_ci   PhysReg reg_v0{256};
195bf215546Sopenharmony_ci   PhysReg reg_v1{257};
196bf215546Sopenharmony_ci
197bf215546Sopenharmony_ci   //! lv1: %tmp1:v[0] = p_unit_test
198bf215546Sopenharmony_ci   Temp tmp = bld.pseudo(aco_opcode::p_unit_test, bld.def(v1.as_linear(), reg_v0));
199bf215546Sopenharmony_ci
200bf215546Sopenharmony_ci   //! lv1: %tmp2:v[1] = p_parallelcopy %tmp1:v[0]
201bf215546Sopenharmony_ci   //! v1: %_:v[0] = p_unit_test
202bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, Definition(reg_v0, v1));
203bf215546Sopenharmony_ci
204bf215546Sopenharmony_ci   //! p_unit_test %tmp2:v[1]
205bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, tmp);
206bf215546Sopenharmony_ci
207bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy());
208bf215546Sopenharmony_ciEND_TEST
209bf215546Sopenharmony_ci
210bf215546Sopenharmony_ciBEGIN_TEST(regalloc.linear_vgpr.live_range_split.get_reg_impl)
211bf215546Sopenharmony_ci   //>> p_startpgm
212bf215546Sopenharmony_ci   if (!setup_cs("", GFX10))
213bf215546Sopenharmony_ci      return;
214bf215546Sopenharmony_ci
215bf215546Sopenharmony_ci   program->dev.vgpr_limit = 3;
216bf215546Sopenharmony_ci
217bf215546Sopenharmony_ci   PhysReg reg_v1{257};
218bf215546Sopenharmony_ci
219bf215546Sopenharmony_ci   //! s1: %scc_tmp:scc, s1: %1:s[0] = p_unit_test
220bf215546Sopenharmony_ci   Temp s0_tmp = bld.tmp(s1);
221bf215546Sopenharmony_ci   Temp scc_tmp = bld.pseudo(aco_opcode::p_unit_test, bld.def(s1, scc), Definition(s0_tmp.id(), PhysReg{0}, s1));
222bf215546Sopenharmony_ci
223bf215546Sopenharmony_ci   //! lv1: %tmp1:v[1] = p_unit_test
224bf215546Sopenharmony_ci   Temp tmp = bld.pseudo(aco_opcode::p_unit_test, bld.def(v1.as_linear(), reg_v1));
225bf215546Sopenharmony_ci
226bf215546Sopenharmony_ci   //! lv1: %tmp2:v[2] = p_parallelcopy %tmp1:v[1]
227bf215546Sopenharmony_ci   //! v2: %_:v[0-1] = p_unit_test
228bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, bld.def(v2));
229bf215546Sopenharmony_ci
230bf215546Sopenharmony_ci   //! p_unit_test %tmp2:v[2], %scc_tmp:scc, %1:s[0]
231bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, tmp, scc_tmp, s0_tmp);
232bf215546Sopenharmony_ci
233bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy());
234bf215546Sopenharmony_ci
235bf215546Sopenharmony_ci   //>> lv1: %5:v[2] = p_parallelcopy %3:v[1] scc:1 scratch:s1
236bf215546Sopenharmony_ci   Pseudo_instruction& parallelcopy = program->blocks[0].instructions[3]->pseudo();
237bf215546Sopenharmony_ci   aco_print_instr(&parallelcopy, output);
238bf215546Sopenharmony_ci   fprintf(output, " scc:%u scratch:s%u\n", parallelcopy.tmp_in_scc, parallelcopy.scratch_sgpr.reg());
239bf215546Sopenharmony_ciEND_TEST
240bf215546Sopenharmony_ci
241bf215546Sopenharmony_ciBEGIN_TEST(regalloc.linear_vgpr.live_range_split.get_regs_for_copies)
242bf215546Sopenharmony_ci   //>> p_startpgm
243bf215546Sopenharmony_ci   if (!setup_cs("", GFX10))
244bf215546Sopenharmony_ci      return;
245bf215546Sopenharmony_ci
246bf215546Sopenharmony_ci   program->dev.vgpr_limit = 6;
247bf215546Sopenharmony_ci
248bf215546Sopenharmony_ci   PhysReg reg_v2{258};
249bf215546Sopenharmony_ci   PhysReg reg_v4{260};
250bf215546Sopenharmony_ci
251bf215546Sopenharmony_ci   //! lv1: %lin_tmp1:v[4] = p_unit_test
252bf215546Sopenharmony_ci   Temp lin_tmp = bld.pseudo(aco_opcode::p_unit_test, bld.def(v1.as_linear(), reg_v4));
253bf215546Sopenharmony_ci   //! v2: %log_tmp1:v[2-3] = p_unit_test
254bf215546Sopenharmony_ci   Temp log_tmp = bld.pseudo(aco_opcode::p_unit_test, bld.def(v2, reg_v2));
255bf215546Sopenharmony_ci
256bf215546Sopenharmony_ci   //! lv1: %lin_tmp2:v[0], v2: %log_tmp2:v[4-5] = p_parallelcopy %lin_tmp1:v[4], %log_tmp1:v[2-3]
257bf215546Sopenharmony_ci   //! v3: %_:v[1-3] = p_unit_test
258bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, bld.def(v3));
259bf215546Sopenharmony_ci
260bf215546Sopenharmony_ci   //! p_unit_test %log_tmp2:v[4-5], %lin_tmp2:v[0]
261bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, log_tmp, lin_tmp);
262bf215546Sopenharmony_ci
263bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy());
264bf215546Sopenharmony_ciEND_TEST
265bf215546Sopenharmony_ci
266bf215546Sopenharmony_ciBEGIN_TEST(regalloc.linear_vgpr.live_range_split.get_reg_create_vector)
267bf215546Sopenharmony_ci   //>> p_startpgm
268bf215546Sopenharmony_ci   if (!setup_cs("", GFX10))
269bf215546Sopenharmony_ci      return;
270bf215546Sopenharmony_ci
271bf215546Sopenharmony_ci   program->dev.vgpr_limit = 4;
272bf215546Sopenharmony_ci
273bf215546Sopenharmony_ci   PhysReg reg_v0{256};
274bf215546Sopenharmony_ci   PhysReg reg_v1{257};
275bf215546Sopenharmony_ci
276bf215546Sopenharmony_ci   //! lv1: %lin_tmp1:v[0] = p_unit_test
277bf215546Sopenharmony_ci   Temp lin_tmp = bld.pseudo(aco_opcode::p_unit_test, bld.def(v1.as_linear(), reg_v0));
278bf215546Sopenharmony_ci   //! v1: %log_tmp:v[1] = p_unit_test
279bf215546Sopenharmony_ci   Temp log_tmp = bld.pseudo(aco_opcode::p_unit_test, bld.def(v1, reg_v1));
280bf215546Sopenharmony_ci
281bf215546Sopenharmony_ci   //! lv1: %lin_tmp2:v[2] = p_parallelcopy %lin_tmp1:v[0]
282bf215546Sopenharmony_ci   //! v2: %_:v[0-1] = p_create_vector v1: undef, %log_tmp:v[1]
283bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_create_vector, bld.def(v2), Operand(v1), log_tmp);
284bf215546Sopenharmony_ci
285bf215546Sopenharmony_ci   //! p_unit_test %lin_tmp2:v[2]
286bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, lin_tmp);
287bf215546Sopenharmony_ci
288bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy());
289bf215546Sopenharmony_ciEND_TEST
290bf215546Sopenharmony_ci
291bf215546Sopenharmony_ciBEGIN_TEST(regalloc.branch_def_phis_at_merge_block)
292bf215546Sopenharmony_ci   //>> p_startpgm
293bf215546Sopenharmony_ci   if (!setup_cs("", GFX10))
294bf215546Sopenharmony_ci      return;
295bf215546Sopenharmony_ci
296bf215546Sopenharmony_ci   //! s2: %_:s[2-3] = p_branch
297bf215546Sopenharmony_ci   bld.branch(aco_opcode::p_branch, bld.def(s2));
298bf215546Sopenharmony_ci
299bf215546Sopenharmony_ci   //! BB1
300bf215546Sopenharmony_ci   //! /* logical preds: / linear preds: BB0, / kind: uniform, */
301bf215546Sopenharmony_ci   bld.reset(program->create_and_insert_block());
302bf215546Sopenharmony_ci   program->blocks[1].linear_preds.push_back(0);
303bf215546Sopenharmony_ci
304bf215546Sopenharmony_ci   //! s2: %tmp:s[0-1] = p_linear_phi 0
305bf215546Sopenharmony_ci   Temp tmp = bld.pseudo(aco_opcode::p_linear_phi, bld.def(s2), Operand::c64(0u));
306bf215546Sopenharmony_ci
307bf215546Sopenharmony_ci   //! p_unit_test %tmp:s[0-1]
308bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, tmp);
309bf215546Sopenharmony_ci
310bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy());
311bf215546Sopenharmony_ciEND_TEST
312bf215546Sopenharmony_ci
313bf215546Sopenharmony_ciBEGIN_TEST(regalloc.branch_def_phis_at_branch_block)
314bf215546Sopenharmony_ci   //>> p_startpgm
315bf215546Sopenharmony_ci   if (!setup_cs("", GFX10))
316bf215546Sopenharmony_ci      return;
317bf215546Sopenharmony_ci
318bf215546Sopenharmony_ci   //! s2: %tmp:s[0-1] = p_unit_test
319bf215546Sopenharmony_ci   Temp tmp = bld.pseudo(aco_opcode::p_unit_test, bld.def(s2));
320bf215546Sopenharmony_ci
321bf215546Sopenharmony_ci   //! s2: %_:s[2-3] = p_cbranch_z %0:scc
322bf215546Sopenharmony_ci   bld.branch(aco_opcode::p_cbranch_z, bld.def(s2), Operand(scc, s1));
323bf215546Sopenharmony_ci
324bf215546Sopenharmony_ci   //! BB1
325bf215546Sopenharmony_ci   //! /* logical preds: / linear preds: BB0, / kind: */
326bf215546Sopenharmony_ci   bld.reset(program->create_and_insert_block());
327bf215546Sopenharmony_ci   program->blocks[1].linear_preds.push_back(0);
328bf215546Sopenharmony_ci
329bf215546Sopenharmony_ci   //! p_unit_test %tmp:s[0-1]
330bf215546Sopenharmony_ci   bld.pseudo(aco_opcode::p_unit_test, tmp);
331bf215546Sopenharmony_ci   bld.branch(aco_opcode::p_branch, bld.def(s2));
332bf215546Sopenharmony_ci
333bf215546Sopenharmony_ci   bld.reset(program->create_and_insert_block());
334bf215546Sopenharmony_ci   program->blocks[2].linear_preds.push_back(0);
335bf215546Sopenharmony_ci
336bf215546Sopenharmony_ci   bld.branch(aco_opcode::p_branch, bld.def(s2));
337bf215546Sopenharmony_ci
338bf215546Sopenharmony_ci   bld.reset(program->create_and_insert_block());
339bf215546Sopenharmony_ci   program->blocks[3].linear_preds.push_back(1);
340bf215546Sopenharmony_ci   program->blocks[3].linear_preds.push_back(2);
341bf215546Sopenharmony_ci
342bf215546Sopenharmony_ci   finish_ra_test(ra_test_policy());
343bf215546Sopenharmony_ciEND_TEST
344