1 /* 2 * Copyright © 2020 Valve Corporation 3 * 4 * SPDX-License-Identifier: MIT 5 */ 6 #include <llvm/Config/llvm-config.h> 7 8 #include "helpers.h" 9 #include "test_isel-spirv.h" 10 11 using namespace aco; 12 13 BEGIN_TEST(isel.interp.simple) 14 QoShaderModuleCreateInfo vs = qoShaderModuleCreateInfoGLSL(VERTEX, 15 layout(location = 0) in vec4 in_color; 16 layout(location = 0) out vec4 out_color; 17 void main() { out_color = in_color; 18 } 19 ); 20 QoShaderModuleCreateInfo fs = qoShaderModuleCreateInfoGLSL(FRAGMENT, 21 layout(location = 0) in vec4 in_color; 22 layout(location = 0) out vec4 out_color; 23 void main() { 24 //>> v1: %b_tmp = v_interp_p1_f32 %bx, %pm:m0 attr0.z 25 //! v1: %b = v_interp_p2_f32 %by, %pm:m0, (kill)%b_tmp attr0.z 26 //! v1: %a_tmp = v_interp_p1_f32 %bx, %pm:m0 attr0.w 27 //! v1: %a = v_interp_p2_f32 %by, %pm:m0, (kill)%a_tmp attr0.w 28 //! v1: %r_tmp = v_interp_p1_f32 %bx, %pm:m0 attr0.x 29 //! v1: %r = v_interp_p2_f32 %by, %pm:m0, (kill)%r_tmp attr0.x 30 //! v1: %g_tmp = v_interp_p1_f32 (kill)%bx, %pm:m0 attr0.y 31 //! v1: %g = v_interp_p2_f32 (kill)%by, (kill)%pm:m0, (kill)%g_tmp attr0.y 32 //! exp (kill)%r, (kill)%g, (kill)%b, (kill)%a mrt0 33 out_color = in_color; 34 } 35 ); 36 37 PipelineBuilder pbld(get_vk_device(GFX9)); 38 pbld.add_vsfs(vs, fs); 39 pbld.print_ir(VK_SHADER_STAGE_FRAGMENT_BIT, "ACO IR"); 40 END_TEST 41 42 BEGIN_TEST(isel.compute.simple) 43 for (unsigned i = GFX7; i <= GFX8; i++) { 44 if (!set_variant((amd_gfx_level)i)) 45 continue; 46 47 QoShaderModuleCreateInfo cs = qoShaderModuleCreateInfoGLSL(COMPUTE, 48 layout(local_size_x=1) in; 49 layout(binding=0) buffer Buf { 50 uint res; 51 }; 52 void main() { 53 //>> v1: %data = p_parallelcopy 42 54 //! buffer_store_dword (kill)%_, v1: undef, 0, (kill)%data disable_wqm storage:buffer 55 res = 42; 56 } 57 ); 58 59 PipelineBuilder pbld(get_vk_device((amd_gfx_level)i)); 60 pbld.add_cs(cs); 61 pbld.print_ir(VK_SHADER_STAGE_COMPUTE_BIT, "ACO IR", true); 62 } 63 END_TEST 64 65 BEGIN_TEST(isel.gs.no_outputs) 66 for (unsigned i = GFX8; i <= GFX10; i++) { 67 if (!set_variant((amd_gfx_level)i)) 68 continue; 69 70 QoShaderModuleCreateInfo vs = qoShaderModuleCreateInfoGLSL(VERTEX, 71 void main() {} 72 ); 73 74 QoShaderModuleCreateInfo gs = qoShaderModuleCreateInfoGLSL(GEOMETRY, 75 layout(points) in; 76 layout(points, max_vertices = 1) out; 77 78 void main() { 79 EmitVertex(); 80 EndPrimitive(); 81 } 82 ); 83 84 PipelineBuilder pbld(get_vk_device((amd_gfx_level)i)); 85 pbld.add_stage(VK_SHADER_STAGE_VERTEX_BIT, vs); 86 pbld.add_stage(VK_SHADER_STAGE_GEOMETRY_BIT, gs); 87 pbld.create_pipeline(); 88 89 //! success 90 fprintf(output, "success\n"); 91 } 92 END_TEST 93 94 BEGIN_TEST(isel.gs.no_verts) 95 for (unsigned i = GFX8; i <= GFX10; i++) { 96 if (!set_variant((amd_gfx_level)i)) 97 continue; 98 99 QoShaderModuleCreateInfo vs = qoShaderModuleCreateInfoGLSL(VERTEX, 100 void main() {} 101 ); 102 103 QoShaderModuleCreateInfo gs = qoShaderModuleCreateInfoGLSL(GEOMETRY, 104 layout(points) in; 105 layout(points, max_vertices = 0) out; 106 107 void main() {} 108 ); 109 110 PipelineBuilder pbld(get_vk_device((amd_gfx_level)i)); 111 pbld.add_stage(VK_SHADER_STAGE_VERTEX_BIT, vs); 112 pbld.add_stage(VK_SHADER_STAGE_GEOMETRY_BIT, gs); 113 pbld.create_pipeline(); 114 115 //! success 116 fprintf(output, "success\n"); 117 } 118 END_TEST 119 120 BEGIN_TEST(isel.sparse.clause) 121 for (unsigned i = GFX10_3; i <= GFX10_3; i++) { 122 if (!set_variant((amd_gfx_level)i)) 123 continue; 124 125 QoShaderModuleCreateInfo cs = qoShaderModuleCreateInfoGLSL(COMPUTE, 126 QO_EXTENSION GL_ARB_sparse_texture2 : require 127 layout(local_size_x=1) in; 128 layout(binding=0) uniform sampler2D tex; 129 layout(binding=1) buffer Buf { 130 vec4 res[4]; 131 uint code[4]; 132 }; 133 void main() { 134 //>> v5: (noCSE)%zero0 = p_create_vector 0, 0, 0, 0, 0 135 //>> v5: %_ = image_sample_lz_o %_, %_, (kill)%zero0, (kill)%_, %_ dmask:xyzw 2d tfe a16 136 //>> v5: (noCSE)%zero1 = p_create_vector 0, 0, 0, 0, 0 137 //>> v5: %_ = image_sample_lz_o %_, %_, (kill)%zero1, (kill)%_, %_ dmask:xyzw 2d tfe a16 138 //>> v5: (noCSE)%zero2 = p_create_vector 0, 0, 0, 0, 0 139 //>> v5: %_ = image_sample_lz_o %_, %_, (kill)%zero2, (kill)%_, %_ dmask:xyzw 2d tfe a16 140 //>> v5: (noCSE)%zero3 = p_create_vector 0, 0, 0, 0, 0 141 //>> v5: %_ = image_sample_lz_o (kill)%_, (kill)%_, (kill)%zero3, (kill)%_, (kill)%_ dmask:xyzw 2d tfe a16 142 //>> s_clause 0x3 143 //! image_sample_lz_o v[#_:#_], v[#_:#_], @s256(img), @s128(samp) dmask:0xf dim:SQ_RSRC_IMG_2D a16 tfe 144 //! image_sample_lz_o v[#_:#_], [v#_, v#_], @s256(img), @s128(samp) dmask:0xf dim:SQ_RSRC_IMG_2D a16 tfe 145 //! image_sample_lz_o v[#_:#_], [v#_, v#_], @s256(img), @s128(samp) dmask:0xf dim:SQ_RSRC_IMG_2D a16 tfe 146 //! image_sample_lz_o v[#_:#_], [v#_, v#_], @s256(img), @s128(samp) dmask:0xf dim:SQ_RSRC_IMG_2D a16 tfe 147 code[0] = sparseTextureOffsetARB(tex, vec2(0.5), ivec2(1, 0), res[0]); 148 code[1] = sparseTextureOffsetARB(tex, vec2(0.5), ivec2(2, 0), res[1]); 149 code[2] = sparseTextureOffsetARB(tex, vec2(0.5), ivec2(3, 0), res[2]); 150 code[3] = sparseTextureOffsetARB(tex, vec2(0.5), ivec2(4, 0), res[3]); 151 } 152 ); 153 154 PipelineBuilder pbld(get_vk_device((amd_gfx_level)i)); 155 pbld.add_cs(cs); 156 pbld.print_ir(VK_SHADER_STAGE_COMPUTE_BIT, "ACO IR", true); 157 pbld.print_ir(VK_SHADER_STAGE_COMPUTE_BIT, "Assembly", true); 158 } 159 END_TEST 160 161 BEGIN_TEST(isel.discard_early_exit.mrtz) 162 QoShaderModuleCreateInfo vs = qoShaderModuleCreateInfoGLSL(VERTEX, 163 void main() {} 164 ); 165 QoShaderModuleCreateInfo fs = qoShaderModuleCreateInfoGLSL(FRAGMENT, 166 void main() { 167 if (gl_FragCoord.w > 0.5) 168 discard; 169 gl_FragDepth = 1.0 / gl_FragCoord.z; 170 } 171 ); 172 173 /* On GFX11, the discard early exit must use mrtz if the shader exports only depth. */ 174 //>> exp mrtz v#_, off, off, off done ; $_ $_ 175 //! s_nop 0 ; $_ 176 //! s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) ; $_ 177 //! s_endpgm ; $_ 178 //! BB1: 179 //! exp mrtz off, off, off, off done ; $_ $_ 180 //! s_nop 0 ; $_ 181 //! s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) ; $_ 182 //! s_endpgm ; $_ 183 184 PipelineBuilder pbld(get_vk_device(GFX11)); 185 pbld.add_vsfs(vs, fs); 186 pbld.print_ir(VK_SHADER_STAGE_FRAGMENT_BIT, "Assembly"); 187 END_TEST 188 189 BEGIN_TEST(isel.discard_early_exit.mrt0) 190 QoShaderModuleCreateInfo vs = qoShaderModuleCreateInfoGLSL(VERTEX, 191 void main() {} 192 ); 193 QoShaderModuleCreateInfo fs = qoShaderModuleCreateInfoGLSL(FRAGMENT, 194 layout(location = 0) out vec4 out_color; 195 void main() { 196 if (gl_FragCoord.w > 0.5) 197 discard; 198 out_color = vec4(1.0 / gl_FragCoord.z); 199 } 200 ); 201 202 /* On GFX11, the discard early exit must use mrt0 if the shader exports color. */ 203 //>> exp mrt0 v#x, v#x, v#x, v#x done ; $_ $_ 204 //! s_nop 0 ; $_ 205 //! s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) ; $_ 206 //! s_endpgm ; $_ 207 //! BB1: 208 //! exp mrt0 off, off, off, off done ; $_ $_ 209 //! s_nop 0 ; $_ 210 //! s_sendmsg sendmsg(MSG_DEALLOC_VGPRS) ; $_ 211 //! s_endpgm ; $_ 212 213 PipelineBuilder pbld(get_vk_device(GFX11)); 214 pbld.add_vsfs(vs, fs); 215 pbld.print_ir(VK_SHADER_STAGE_FRAGMENT_BIT, "Assembly"); 216 END_TEST 217 218 BEGIN_TEST(isel.s_bfe_mask_bits) 219 QoShaderModuleCreateInfo cs = qoShaderModuleCreateInfoGLSL(COMPUTE, 220 layout(local_size_x=1) in; 221 layout(binding=0) buffer Buf { 222 int res; 223 }; 224 void main() { 225 //>> s1: %bits, s1: (kill)%_:scc = s_and_b32 (kill)%_, 31 226 //! s1: %src1 = s_pack_ll_b32_b16 0, (kill)%bits 227 //! s1: %_, s1: (kill)%_:scc = s_bfe_i32 0xdeadbeef, (kill)%src1 228 res = bitfieldExtract(0xdeadbeef, 0, res & 0x1f); 229 } 230 ); 231 232 PipelineBuilder pbld(get_vk_device(GFX10_3)); 233 pbld.add_cs(cs); 234 pbld.print_ir(VK_SHADER_STAGE_COMPUTE_BIT, "ACO IR", true); 235 END_TEST 236 237 /** 238 * loop { 239 * if (uniform) { 240 * break; 241 * } else { 242 * break; 243 * } 244 * // unreachable continue 245 * } 246 */ 247 BEGIN_TEST(isel.cf.unreachable_continue.uniform_break) 248 if (!setup_nir_cs(GFX11)) 249 return; 250 251 //>> s1: %init0 = p_unit_test 0 252 //>> v1: %init1 = p_unit_test 1 253 nir_def *init0 = nir_unit_test_uniform_amd(nb, 1, 32, .base=0); 254 nir_def *init1 = nir_unit_test_divergent_amd(nb, 1, 32, .base=1); 255 nir_phi_instr *phi[2]; 256 257 nir_loop *loop = nir_push_loop(nb); 258 { 259 //>> BB1 260 //! /* logical preds: BB0, / linear preds: BB0, / kind: uniform, loop-header, */ 261 //! v1: %_ = p_phi %init1 262 //! s1: %_ = p_linear_phi %init0 263 phi[0] = nir_phi_instr_create(nb->shader); 264 phi[1] = nir_phi_instr_create(nb->shader); 265 nir_def_init(&phi[0]->instr, &phi[0]->def, 1, 32); 266 nir_def_init(&phi[1]->instr, &phi[1]->def, 1, 32); 267 nir_phi_instr_add_src(phi[0], init0->parent_instr->block, init0); 268 nir_phi_instr_add_src(phi[1], init1->parent_instr->block, init1); 269 270 nir_push_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base=4)); 271 { 272 //>> BB2 273 //! /* logical preds: BB1, / linear preds: BB1, / kind: uniform, break, */ 274 nir_jump(nb, nir_jump_break); 275 } 276 nir_push_else(nb, NULL); 277 { 278 /* The contents of this branch is moved to the merge block. */ 279 //>> BB3 280 //! /* logical preds: BB1, / linear preds: BB1, / kind: uniform, */ 281 //>> BB4 282 //! /* logical preds: BB3, / linear preds: BB3, / kind: uniform, break, */ 283 //! p_logical_start 284 //! s1: %_ = p_unit_test 5 285 //! p_logical_end 286 nir_unit_test_uniform_amd(nb, 1, 32, .base=5); 287 nir_jump(nb, nir_jump_break); 288 } 289 nir_pop_if(nb, NULL); 290 291 nir_def *cont0 = nir_unit_test_uniform_amd(nb, 1, 32, .base=2); 292 nir_def *cont1 = nir_unit_test_divergent_amd(nb, 1, 32, .base=3); 293 294 nir_phi_instr_add_src(phi[0], nir_loop_last_block(loop), cont0); 295 nir_phi_instr_add_src(phi[1], nir_loop_last_block(loop), cont1); 296 } 297 nir_pop_loop(nb, NULL); 298 299 nb->cursor = nir_after_phis(nir_loop_first_block(loop)); 300 nir_builder_instr_insert(nb, &phi[0]->instr); 301 nir_builder_instr_insert(nb, &phi[1]->instr); 302 nir_unit_test_amd(nb, &phi[0]->def); 303 nir_unit_test_amd(nb, &phi[1]->def); 304 305 finish_isel_test(); 306 END_TEST 307 308 /** 309 * loop { 310 * if (divergent) { 311 * break; 312 * } else { 313 * break; 314 * } 315 * // unreachable continue 316 * } 317 */ 318 BEGIN_TEST(isel.cf.unreachable_continue.divergent_break) 319 if (!setup_nir_cs(GFX11)) 320 return; 321 322 //>> s1: %init0 = p_unit_test 0 323 //>> v1: %init1 = p_unit_test 1 324 nir_def *init0 = nir_unit_test_uniform_amd(nb, 1, 32, .base=0); 325 nir_def *init1 = nir_unit_test_divergent_amd(nb, 1, 32, .base=1); 326 nir_phi_instr *phi[2]; 327 328 nir_loop *loop = nir_push_loop(nb); 329 { 330 //>> BB1 331 //! /* logical preds: BB0, / linear preds: BB0, / kind: loop-header, branch, */ 332 //! v1: %_ = p_phi %init1 333 //! s1: %_ = p_linear_phi %init0 334 phi[0] = nir_phi_instr_create(nb->shader); 335 phi[1] = nir_phi_instr_create(nb->shader); 336 nir_def_init(&phi[0]->instr, &phi[0]->def, 1, 32); 337 nir_def_init(&phi[1]->instr, &phi[1]->def, 1, 32); 338 nir_phi_instr_add_src(phi[0], init0->parent_instr->block, init0); 339 nir_phi_instr_add_src(phi[1], init1->parent_instr->block, init1); 340 341 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base=4)); 342 { 343 //>> BB2 344 //! /* logical preds: BB1, / linear preds: BB1, / kind: break, */ 345 nir_jump(nb, nir_jump_break); 346 } 347 nir_push_else(nb, NULL); 348 { 349 /* The contents of this branch is moved to the merge block. */ 350 //>> BB7 351 //! /* logical preds: BB1, / linear preds: BB6, / kind: uniform, */ 352 //>> BB9 353 //! /* logical preds: BB7, / linear preds: BB7, BB8, / kind: uniform, break, merge, */ 354 //! p_logical_start 355 //! s1: %_ = p_unit_test 5 356 //! p_logical_end 357 nir_unit_test_uniform_amd(nb, 1, 32, .base=5); 358 nir_jump(nb, nir_jump_break); 359 } 360 nir_pop_if(nb, NULL); 361 362 nir_def *cont0 = nir_unit_test_uniform_amd(nb, 1, 32, .base=2); 363 nir_def *cont1 = nir_unit_test_divergent_amd(nb, 1, 32, .base=3); 364 365 nir_phi_instr_add_src(phi[0], nir_loop_last_block(loop), cont0); 366 nir_phi_instr_add_src(phi[1], nir_loop_last_block(loop), cont1); 367 } 368 nir_pop_loop(nb, NULL); 369 370 nb->cursor = nir_after_phis(nir_loop_first_block(loop)); 371 nir_builder_instr_insert(nb, &phi[0]->instr); 372 nir_builder_instr_insert(nb, &phi[1]->instr); 373 nir_unit_test_amd(nb, &phi[0]->def); 374 nir_unit_test_amd(nb, &phi[1]->def); 375 376 finish_isel_test(); 377 END_TEST 378 379 /** 380 * loop { 381 * if (uniform) { 382 * continue; 383 * } else { 384 * continue; 385 * } 386 * // unreachable block 387 * break; 388 * } 389 */ 390 BEGIN_TEST(isel.cf.unreachable_break.uniform_continue) 391 if (!setup_nir_cs(GFX11)) 392 return; 393 394 nir_def *val0; 395 nir_def *val1; 396 397 /* These are undefs. */ 398 //>> s3: %val1 = p_create_vector 0, 0, 0 399 //>> s1: %val0 = p_parallelcopy 0 400 401 nir_push_loop(nb); 402 { 403 //>> BB1 404 //! /* logical preds: BB0, BB2, BB7, / linear preds: BB0, BB2, BB7, / kind: uniform, loop-header, */ 405 nir_push_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base=2)); 406 { 407 //>> BB2 408 //! /* logical preds: BB1, / linear preds: BB1, / kind: uniform, continue, */ 409 nir_jump(nb, nir_jump_continue); 410 } 411 nir_push_else(nb, NULL); 412 { 413 /* The contents of this branch is moved to the merge block, and a dummy break is inserted 414 * before the continue so that the loop has an exit. 415 */ 416 //>> BB3 417 //! /* logical preds: BB1, / linear preds: BB1, / kind: uniform, */ 418 //>> BB4 419 //! /* logical preds: BB3, / linear preds: BB3, / kind: uniform, */ 420 //! p_logical_start 421 //! s1: %_ = p_unit_test 5 422 //! s2: %zero = p_parallelcopy 0 423 //! s2: %_, s1: %cond:scc = s_and_b64 %zero, %0:exec 424 //! p_logical_end 425 //! p_cbranch_z %cond:scc 426 //! BB5 427 //! /* logical preds: BB4, / linear preds: BB4, / kind: uniform, break, */ 428 //>> BB6 429 //! /* logical preds: BB4, / linear preds: BB4, / kind: uniform, */ 430 //>> BB7 431 //! /* logical preds: BB6, / linear preds: BB6, / kind: uniform, continue, */ 432 nir_unit_test_uniform_amd(nb, 1, 32, .base=5); 433 nir_jump(nb, nir_jump_continue); 434 } 435 nir_pop_if(nb, NULL); 436 437 val0 = nir_imm_zero(nb, 1, 32); 438 val1 = nir_load_local_invocation_id(nb); 439 440 nir_jump(nb, nir_jump_break); 441 } 442 nir_pop_loop(nb, NULL); 443 //>> BB8 444 //! /* logical preds: BB5, / linear preds: BB5, / kind: uniform, top-level, loop-exit, */ 445 446 //>> p_unit_test 0, %val0 447 //! p_unit_test 1, %val1 448 nir_unit_test_amd(nb, val0, .base=0); 449 nir_unit_test_amd(nb, val1, .base=1); 450 451 finish_isel_test(); 452 END_TEST 453 454 /** 455 * loop { 456 * if (uniform) { 457 * break; 458 * } else { 459 * if (divergent) { 460 * break; 461 * } else { 462 * break; 463 * } 464 * } 465 * // unreachable continue 466 * } 467 */ 468 BEGIN_TEST(isel.cf.unreachable_continue.mixed_break) 469 if (!setup_nir_cs(GFX11)) 470 return; 471 472 //>> s1: %init0 = p_unit_test 0 473 //>> v1: %init1 = p_unit_test 1 474 nir_def *init0 = nir_unit_test_uniform_amd(nb, 1, 32, .base=0); 475 nir_def *init1 = nir_unit_test_divergent_amd(nb, 1, 32, .base=1); 476 nir_phi_instr *phi[2]; 477 478 nir_loop *loop = nir_push_loop(nb); 479 { 480 //>> BB1 481 //! /* logical preds: BB0, / linear preds: BB0, / kind: uniform, loop-header, */ 482 //! v1: %_ = p_phi %init1 483 //! s1: %_ = p_linear_phi %init0 484 phi[0] = nir_phi_instr_create(nb->shader); 485 phi[1] = nir_phi_instr_create(nb->shader); 486 nir_def_init(&phi[0]->instr, &phi[0]->def, 1, 32); 487 nir_def_init(&phi[1]->instr, &phi[1]->def, 1, 32); 488 nir_phi_instr_add_src(phi[0], init0->parent_instr->block, init0); 489 nir_phi_instr_add_src(phi[1], init1->parent_instr->block, init1); 490 491 nir_push_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base=4)); 492 { 493 //>> BB2 494 //! /* logical preds: BB1, / linear preds: BB1, / kind: uniform, break, */ 495 nir_jump(nb, nir_jump_break); 496 } 497 nir_push_else(nb, NULL); 498 { 499 /* The contents of this branch is moved to the merge block. */ 500 //>> BB3 501 //! /* logical preds: BB1, / linear preds: BB1, / kind: uniform, */ 502 //>> BB4 503 //! /* logical preds: BB3, / linear preds: BB3, / kind: branch, */ 504 //! p_logical_start 505 //! s2: %cond = p_unit_test 5 506 //! p_logical_end 507 //! p_cbranch_z %cond 508 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base=5)); 509 { 510 //>> BB5 511 //! /* logical preds: BB4, / linear preds: BB4, / kind: break, */ 512 nir_jump(nb, nir_jump_break); 513 } 514 nir_push_else(nb, NULL); 515 { 516 /* The contents of this branch is moved to the merge block. */ 517 //>> BB10 518 //! /* logical preds: BB4, / linear preds: BB9, / kind: uniform, */ 519 //>> BB12 520 //! /* logical preds: BB10, / linear preds: BB10, BB11, / kind: uniform, break, merge, */ 521 //! p_logical_start 522 //! s1: %_ = p_unit_test 6 523 nir_unit_test_uniform_amd(nb, 1, 32, .base=6); 524 nir_jump(nb, nir_jump_break); 525 } 526 nir_pop_if(nb, NULL); 527 } 528 nir_pop_if(nb, NULL); 529 530 nir_def *cont0 = nir_unit_test_uniform_amd(nb, 1, 32, .base=2); 531 nir_def *cont1 = nir_unit_test_divergent_amd(nb, 1, 32, .base=3); 532 533 nir_phi_instr_add_src(phi[0], nir_loop_last_block(loop), cont0); 534 nir_phi_instr_add_src(phi[1], nir_loop_last_block(loop), cont1); 535 } 536 nir_pop_loop(nb, NULL); 537 //>> BB13 538 //! /* logical preds: BB2, BB5, BB12, / linear preds: BB2, BB6, BB12, / kind: uniform, top-level, loop-exit, */ 539 540 nb->cursor = nir_after_phis(nir_loop_first_block(loop)); 541 nir_builder_instr_insert(nb, &phi[0]->instr); 542 nir_builder_instr_insert(nb, &phi[1]->instr); 543 nir_unit_test_amd(nb, &phi[0]->def); 544 nir_unit_test_amd(nb, &phi[1]->def); 545 546 finish_isel_test(); 547 END_TEST 548 549 /** 550 * loop { 551 * if (uniform) { 552 * break; 553 * } else { 554 * if (uniform) { 555 * break; 556 * } else { 557 * if (divergent) { 558 * break; 559 * } else { 560 * break; 561 * } 562 * } 563 * } 564 * // unreachable continue 565 * } 566 */ 567 BEGIN_TEST(isel.cf.unreachable_continue.nested_mixed_break) 568 if (!setup_nir_cs(GFX11)) 569 return; 570 571 //>> s1: %init0 = p_unit_test 0 572 //>> v1: %init1 = p_unit_test 1 573 nir_def *init0 = nir_unit_test_uniform_amd(nb, 1, 32, .base=0); 574 nir_def *init1 = nir_unit_test_divergent_amd(nb, 1, 32, .base=1); 575 nir_phi_instr *phi[2]; 576 577 nir_loop *loop = nir_push_loop(nb); 578 { 579 //>> BB1 580 //! /* logical preds: BB0, / linear preds: BB0, / kind: uniform, loop-header, */ 581 //! v1: %_ = p_phi %init1 582 //! s1: %_ = p_linear_phi %init0 583 phi[0] = nir_phi_instr_create(nb->shader); 584 phi[1] = nir_phi_instr_create(nb->shader); 585 nir_def_init(&phi[0]->instr, &phi[0]->def, 1, 32); 586 nir_def_init(&phi[1]->instr, &phi[1]->def, 1, 32); 587 nir_phi_instr_add_src(phi[0], init0->parent_instr->block, init0); 588 nir_phi_instr_add_src(phi[1], init1->parent_instr->block, init1); 589 590 nir_push_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base=4)); 591 { 592 //>> BB2 593 //! /* logical preds: BB1, / linear preds: BB1, / kind: uniform, break, */ 594 nir_jump(nb, nir_jump_break); 595 } 596 nir_push_else(nb, NULL); 597 { 598 /* The contents of this branch is moved to the merge block. */ 599 //>> BB3 600 //! /* logical preds: BB1, / linear preds: BB1, / kind: uniform, */ 601 //>> BB4 602 //! /* logical preds: BB3, / linear preds: BB3, / kind: uniform, */ 603 //! p_logical_start 604 //! s2: %cond1 = p_unit_test 4 605 //! s2: %_, s1: %_:scc = s_and_b64 %cond1, %0:exec 606 //! p_logical_end 607 //! p_cbranch_z %_:scc 608 nir_push_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base=4)); 609 { 610 //>> BB5 611 //! /* logical preds: BB4, / linear preds: BB4, / kind: uniform, break, */ 612 nir_jump(nb, nir_jump_break); 613 } 614 nir_push_else(nb, NULL); 615 { 616 /* The contents of this branch is moved to the merge block. */ 617 //>> BB6 618 //! /* logical preds: BB4, / linear preds: BB4, / kind: uniform, */ 619 //>> BB7 620 //! /* logical preds: BB6, / linear preds: BB6, / kind: branch, */ 621 //! p_logical_start 622 //! s2: %cond2 = p_unit_test 5 623 //! p_logical_end 624 //! p_cbranch_z %cond2 625 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base=5)); 626 { 627 //>> BB8 628 //! /* logical preds: BB7, / linear preds: BB7, / kind: break, */ 629 nir_jump(nb, nir_jump_break); 630 } 631 nir_push_else(nb, NULL); 632 { 633 /* The contents of this branch is moved to the merge block. */ 634 //>> BB13 635 //! /* logical preds: BB7, / linear preds: BB12, / kind: uniform, */ 636 //>> BB15 637 //! /* logical preds: BB13, / linear preds: BB13, BB14, / kind: uniform, break, merge, */ 638 nir_jump(nb, nir_jump_break); 639 } 640 nir_pop_if(nb, NULL); 641 } 642 nir_pop_if(nb, NULL); 643 } 644 nir_pop_if(nb, NULL); 645 646 nir_def *cont0 = nir_unit_test_uniform_amd(nb, 1, 32, .base=2); 647 nir_def *cont1 = nir_unit_test_divergent_amd(nb, 1, 32, .base=3); 648 649 nir_phi_instr_add_src(phi[0], nir_loop_last_block(loop), cont0); 650 nir_phi_instr_add_src(phi[1], nir_loop_last_block(loop), cont1); 651 } 652 nir_pop_loop(nb, NULL); 653 654 nb->cursor = nir_after_phis(nir_loop_first_block(loop)); 655 nir_builder_instr_insert(nb, &phi[0]->instr); 656 nir_builder_instr_insert(nb, &phi[1]->instr); 657 nir_unit_test_amd(nb, &phi[0]->def); 658 nir_unit_test_amd(nb, &phi[1]->def); 659 660 finish_isel_test(); 661 END_TEST 662 663 /** 664 * loop { 665 * continue; 666 * } 667 */ 668 BEGIN_TEST(isel.cf.unreachable_loop_exit) 669 if (!setup_nir_cs(GFX11)) 670 return; 671 672 nir_push_loop(nb); 673 { 674 /* A dummy break is inserted before the continue so that the loop has an exit. */ 675 //>> BB1 676 //! /* logical preds: BB0, BB4, / linear preds: BB0, BB4, / kind: uniform, loop-header, */ 677 //>> s1: %_ = p_unit_test 0 678 //>> s2: %zero = p_parallelcopy 0 679 //>> s2: %_, s1: %cond:scc = s_and_b64 %zero, %0:exec 680 //>> p_cbranch_z %cond:scc 681 //! BB2 682 //! /* logical preds: BB1, / linear preds: BB1, / kind: uniform, break, */ 683 //>> BB4 684 //! /* logical preds: BB3, / linear preds: BB3, / kind: uniform, continue, */ 685 nir_unit_test_uniform_amd(nb, 1, 32, .base=0); 686 nir_jump(nb, nir_jump_continue); 687 } 688 nir_pop_loop(nb, NULL); 689 690 finish_isel_test(); 691 END_TEST 692 693 /** 694 * loop { 695 * if (divergent) { 696 * break; 697 * } else { 698 * val = uniform; 699 * } 700 * use(val); 701 * } 702 */ 703 BEGIN_TEST(isel.cf.divergent_if_branch_use) 704 if (!setup_nir_cs(GFX11)) 705 return; 706 707 nir_push_loop(nb); 708 { 709 nir_def *val; 710 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base=2)); 711 { 712 //>> BB2 713 //! /* logical preds: BB1, / linear preds: BB1, / kind: break, */ 714 nir_jump(nb, nir_jump_break); 715 } 716 nir_push_else(nb, NULL); 717 { 718 /* The contents of this branch is moved to the merge block. */ 719 //>> BB9 720 //! /* logical preds: BB7, / linear preds: BB7, BB8, / kind: uniform, continue, merge, */ 721 //! p_logical_start 722 //! s1: %val = p_unit_test 0 723 val = nir_unit_test_uniform_amd(nb, 1, 32, .base=0); 724 } 725 nir_pop_if(nb, NULL); 726 727 //! p_unit_test 1, %val 728 nir_unit_test_amd(nb, val, .base=1); 729 } 730 nir_pop_loop(nb, NULL); 731 732 finish_isel_test(); 733 END_TEST 734 735 /** 736 * loop { 737 * if (divergent) { 738 * continue; 739 * } 740 * if (uniform) { 741 * break; 742 * } else { 743 * val = uniform; 744 * } 745 * use(val); 746 * } 747 */ 748 BEGIN_TEST(isel.cf.uniform_if_branch_use) 749 if (!setup_nir_cs(GFX11)) 750 return; 751 752 nir_push_loop(nb); 753 { 754 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base=3)); 755 { 756 nir_jump(nb, nir_jump_continue); 757 } 758 nir_pop_if(nb, NULL); 759 760 //>> s2: %cond = p_unit_test 2 761 //! s2: %_, s1: %_:scc = s_and_b64 %cond, %0:exec 762 //! p_logical_end 763 //! p_cbranch_z %_:scc 764 nir_def *val; 765 nir_push_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base=2)); 766 { 767 //>> BB10 768 //! /* logical preds: BB9, / linear preds: BB9, / kind: break, */ 769 nir_jump(nb, nir_jump_break); 770 } 771 nir_push_else(nb, NULL); 772 { 773 /* The contents of this branch is moved to the merge block. */ 774 //>> BB14 775 //! /* logical preds: BB13, / linear preds: BB12, BB13, / kind: uniform, */ 776 //>> p_cbranch_z %0:exec rarely_taken 777 //! BB15 778 //! /* logical preds: BB14, / linear preds: BB14, / kind: uniform, */ 779 //! p_logical_start 780 //! s1: %val = p_unit_test 0 781 val = nir_unit_test_uniform_amd(nb, 1, 32, .base=0); 782 } 783 nir_pop_if(nb, NULL); 784 785 //! p_unit_test 1, %val 786 nir_unit_test_amd(nb, val, .base=1); 787 788 //>> BB17 789 //! /* logical preds: BB15, / linear preds: BB15, BB16, / kind: uniform, continue, */ 790 } 791 nir_pop_loop(nb, NULL); 792 793 finish_isel_test(); 794 END_TEST 795 796 /** 797 * b = ... 798 * loop { 799 * a = linear_phi b, c, d 800 * if (divergent) { 801 * c = ... 802 * continue 803 * } 804 * d = c or undef 805 * break 806 * } 807 */ 808 BEGIN_TEST(isel.cf.hidden_continue) 809 if (!setup_nir_cs(GFX11)) 810 return; 811 812 //>> s1: %init = p_unit_test 0 813 nir_def* init = nir_unit_test_uniform_amd(nb, 1, 32, .base = 0); 814 nir_phi_instr* phi; 815 816 nir_loop* loop = nir_push_loop(nb); 817 { 818 //>> BB1 819 //! /* logical preds: BB0, BB2, / linear preds: BB0, BB3, BB11, / kind: loop-header, branch, */ 820 //! s1: %2 = p_linear_phi %init, %cont, %phi 821 phi = nir_phi_instr_create(nb->shader); 822 nir_def_init(&phi->instr, &phi->def, 1, 32); 823 nir_phi_instr_add_src(phi, init->parent_instr->block, init); 824 825 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 4)); 826 { 827 //>> BB2 828 //! /* logical preds: BB1, / linear preds: BB1, / kind: continue, */ 829 //! p_logical_start 830 //! s1: %cont = p_unit_test 1 831 nir_def* cont = nir_unit_test_uniform_amd(nb, 1, 32, .base = 1); 832 nir_phi_instr_add_src(phi, cont->parent_instr->block, cont); 833 nir_jump(nb, nir_jump_continue); 834 } 835 nir_pop_if(nb, NULL); 836 //>> BB6 837 //! /* logical preds: / linear preds: BB4, BB5, / kind: invert, */ 838 //! s1: %phi = p_linear_phi %cont, s1: undef 839 840 //>> BB9 841 //! /* logical preds: BB7, / linear preds: BB7, BB8, / kind: break, merge, */ 842 //>> BB11 843 //! /* logical preds: / linear preds: BB9, / kind: uniform, continue, */ 844 nir_jump(nb, nir_jump_break); 845 } 846 nir_pop_loop(nb, NULL); 847 848 nb->cursor = nir_after_phis(nir_loop_first_block(loop)); 849 nir_builder_instr_insert(nb, &phi->instr); 850 nir_unit_test_amd(nb, &phi->def); 851 852 finish_isel_test(); 853 END_TEST 854 855 /** 856 * a = ... 857 * loop { 858 * if (uniform) { 859 * break 860 * } 861 * terminate_if 862 * } 863 * b = phi a 864 */ 865 BEGIN_TEST(isel.cf.hidden_break) 866 if (!setup_nir_cs(GFX11)) 867 return; 868 869 //>> s1: %brk = p_unit_test 0 870 nir_def* brk = nir_unit_test_uniform_amd(nb, 1, 32, .base = 0); 871 nir_block* block; 872 nir_push_loop(nb); 873 { 874 nir_push_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base = 4)); 875 { 876 block = nir_cursor_current_block(nb->cursor); 877 nir_jump(nb, nir_jump_break); 878 } 879 nir_pop_if(nb, NULL); 880 //>> BB4 881 //! /* logical preds: BB3, / linear preds: BB3, / kind: uniform, continue_or_break, discard, */ 882 883 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 5)); 884 } 885 nir_pop_loop(nb, NULL); 886 887 //>> BB7 888 //! /* logical preds: BB2, / linear preds: BB2, BB5, / kind: uniform, top-level, loop-exit, */ 889 //! s1: %4 = p_linear_phi %1, s1: undef 890 nir_phi_instr* phi = nir_phi_instr_create(nb->shader); 891 nir_def_init(&phi->instr, &phi->def, 1, 32); 892 nir_phi_instr_add_src(phi, block, brk); 893 nir_builder_instr_insert(nb, &phi->instr); 894 nir_unit_test_amd(nb, &phi->def); 895 896 finish_isel_test(); 897 END_TEST 898 899 /** 900 * loop { 901 * if (divergent) { 902 * a = loop_invariant_sgpr 903 * break 904 * } 905 * terminate_if 906 * } 907 * use(a) 908 */ 909 BEGIN_TEST(isel.cf.hidden_break_no_lcssa) 910 if (!setup_nir_cs(GFX11)) 911 return; 912 913 nir_def* val; 914 nir_push_loop(nb); 915 { 916 //>> BB1 917 //! /* logical preds: BB0, BB9, / linear preds: BB0, BB11, / kind: loop-header, branch, */ 918 //! s1: %val_header_phi = p_linear_phi s1: undef, %val_invert_phi 919 920 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 1)); 921 { 922 //>> BB2 923 //! /* logical preds: BB1, / linear preds: BB1, / kind: break, */ 924 //! p_logical_start 925 //! s1: %val = p_parallelcopy 0 926 val = nir_imm_zero(nb, 1, 32); 927 nir_jump(nb, nir_jump_break); 928 } 929 nir_pop_if(nb, NULL); 930 931 //>> BB6 932 //! /* logical preds: / linear preds: BB4, BB5, / kind: invert, */ 933 //! s1: %val_invert_phi = p_linear_phi %val, %val_header_phi 934 //>> BB9 935 //! /* logical preds: BB7, / linear preds: BB7, BB8, / kind: uniform, continue_or_break, merge, discard, */ 936 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 2)); 937 } 938 nir_pop_loop(nb, NULL); 939 940 //>> BB12 941 //! /* logical preds: BB2, / linear preds: BB3, BB10, / kind: uniform, top-level, loop-exit, */ 942 //! s1: %val_exit_phi = p_linear_phi %val, %val_invert_phi 943 //! p_logical_start 944 //! p_unit_test 0, %val_exit_phi 945 nir_unit_test_amd(nb, val, .base = 0); 946 947 finish_isel_test(); 948 END_TEST 949 950 /** 951 * loop { 952 * use(phi(, a)) 953 * loop { 954 * terminate_if 955 * if (uniform) { 956 * a = loop_invariant_sgpr 957 * break 958 * } 959 * } 960 * } 961 */ 962 BEGIN_TEST(isel.cf.hidden_break_no_lcssa_header_phi) 963 if (!setup_nir_cs(GFX11)) 964 return; 965 966 //>> p_startpgm 967 //! p_logical_start 968 //! s1: %init = p_unit_test 0 969 nir_def* init = nir_unit_test_uniform_amd(nb, 1, 32, .base = 0); 970 971 nir_def* val; 972 nir_phi_instr* phi; 973 nir_loop *loop = nir_push_loop(nb); 974 { 975 //>> BB1 976 //! /* logical preds: BB0, BB17, / linear preds: BB0, BB19, / kind: uniform, loop-preheader, loop-header, */ 977 //! s1: %phi = p_linear_phi %init, %val_lcssa 978 //! p_logical_start 979 //! p_unit_test 1, %phi 980 phi = nir_phi_instr_create(nb->shader); 981 nir_def_init(&phi->instr, &phi->def, 1, 32); 982 nir_phi_instr_add_src(phi, init->parent_instr->block, init); 983 nir_unit_test_amd(nb, &phi->def, .base = 1); 984 985 //>> BB2 986 //! /* logical preds: BB1, BB8, / linear preds: BB1, BB10, / kind: uniform, loop-header, discard, */ 987 nir_push_loop(nb); 988 { 989 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 2)); 990 991 nir_push_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base = 3)); 992 { 993 //>> BB4 994 //! /* logical preds: BB3, / linear preds: BB3, / kind: uniform, break, */ 995 //! p_logical_start 996 //! s1: %val = p_parallelcopy 0 997 val = nir_imm_zero(nb, 1, 32); 998 nir_jump(nb, nir_jump_break); 999 } 1000 nir_pop_if(nb, NULL); 1001 //>> BB8 1002 //! /* logical preds: BB6, / linear preds: BB6, BB7, / kind: uniform, continue_or_break, */ 1003 } 1004 nir_pop_loop(nb, NULL); 1005 //>> BB11 1006 //! /* logical preds: BB4, / linear preds: BB4, BB9, / kind: uniform, loop-exit, */ 1007 //! s1: %val_lcssa = p_linear_phi %val, s1: undef 1008 //>> BB17 1009 //! /* logical preds: BB15, / linear preds: BB15, BB16, / kind: uniform, continue_or_break, */ 1010 1011 nir_phi_instr_add_src(phi, nir_cursor_current_block(nb->cursor), val); 1012 } 1013 nir_pop_loop(nb, NULL); 1014 1015 nb->cursor = nir_after_phis(nir_loop_first_block(loop)); 1016 nir_builder_instr_insert(nb, &phi->instr); 1017 1018 finish_isel_test(); 1019 END_TEST 1020 1021 /** 1022 * if (divergent) { 1023 * a = 1024 * } else { 1025 * } 1026 * b = phi(a, undef); 1027 * } 1028 */ 1029 BEGIN_TEST(isel.cf.divergent_if_undef.basic_then) 1030 if (!setup_nir_cs(GFX11)) 1031 return; 1032 1033 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 2)); 1034 //>> BB1 1035 //! /* logical preds: BB0, / linear preds: BB0, / kind: uniform, */ 1036 //! p_logical_start 1037 //! s1: %val = p_unit_test 0 1038 nir_def* val = nir_unit_test_uniform_amd(nb, 1, 32, .base = 0); 1039 nir_pop_if(nb, NULL); 1040 1041 //>> BB3 1042 //! /* logical preds: / linear preds: BB1, BB2, / kind: invert, */ 1043 //! s1: %phi = p_linear_phi %val, s1: undef 1044 //>> BB6 1045 //! /* logical preds: BB1, BB4, / linear preds: BB4, BB5, / kind: uniform, top-level, merge, */ 1046 //! s1: %phi2 = p_linear_phi %phi, %phi 1047 //! p_logical_start 1048 //! p_unit_test 1, %phi2 1049 nir_unit_test_amd(nb, nir_if_phi(nb, val, nir_undef(nb, 1, 32)), .base = 1); 1050 1051 finish_isel_test(); 1052 END_TEST 1053 1054 /** 1055 * if (divergent) { 1056 * } else { 1057 * a = 1058 * } 1059 * b = phi(undef, a); 1060 * } 1061 */ 1062 BEGIN_TEST(isel.cf.divergent_if_undef.basic_else) 1063 if (!setup_nir_cs(GFX11)) 1064 return; 1065 1066 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 2)); 1067 nir_push_else(nb, NULL); 1068 //>> BB3 1069 //! /* logical preds: / linear preds: BB1, BB2, / kind: invert, */ 1070 //>> BB4 1071 //! /* logical preds: BB0, / linear preds: BB3, / kind: uniform, */ 1072 //! p_logical_start 1073 //! s1: %val = p_unit_test 0 1074 nir_def* val = nir_unit_test_uniform_amd(nb, 1, 32, .base = 0); 1075 nir_pop_if(nb, NULL); 1076 1077 //>> BB6 1078 //! /* logical preds: BB1, BB4, / linear preds: BB4, BB5, / kind: uniform, top-level, merge, */ 1079 //! s1: %phi = p_linear_phi %val, s1: undef 1080 //! p_logical_start 1081 //! p_unit_test 1, %phi 1082 nir_unit_test_amd(nb, nir_if_phi(nb, nir_undef(nb, 1, 32), val), .base = 1); 1083 1084 finish_isel_test(); 1085 END_TEST 1086 1087 /** 1088 * loop { 1089 * a = 1090 * if (divergent) { 1091 * break; 1092 * } else { 1093 * } 1094 * b = phi(a); 1095 * } 1096 */ 1097 BEGIN_TEST(isel.cf.divergent_if_undef.break) 1098 if (!setup_nir_cs(GFX11)) 1099 return; 1100 1101 nir_push_loop(nb); 1102 { 1103 //>> BB1 1104 //! /* logical preds: BB0, BB9, / linear preds: BB0, BB9, / kind: loop-header, branch, */ 1105 //! p_logical_start 1106 //! s1: %val = p_unit_test 0 1107 //! s2: %_ = p_unit_test 2 1108 nir_def* val = nir_unit_test_uniform_amd(nb, 1, 32, .base = 0); 1109 nir_if* nif = nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 2)); 1110 { 1111 //>> BB2 1112 //! /* logical preds: BB1, / linear preds: BB1, / kind: break, */ 1113 nir_jump(nb, nir_jump_break); 1114 } 1115 nir_push_else(nb, NULL); 1116 {} 1117 nir_pop_if(nb, NULL); 1118 1119 //>> BB9 1120 //! /* logical preds: BB7, / linear preds: BB7, BB8, / kind: uniform, continue, merge, */ 1121 //! s1: %phi = p_linear_phi %val, s1: undef 1122 nir_phi_instr* phi = nir_phi_instr_create(nb->shader); 1123 nir_phi_instr_add_src(phi, nir_if_last_else_block(nif), val); 1124 nir_def_init(&phi->instr, &phi->def, 1, 32); 1125 nir_builder_instr_insert(nb, &phi->instr); 1126 1127 //! p_logical_start 1128 //! p_unit_test 1, %phi 1129 nir_unit_test_amd(nb, &phi->def, .base = 1); 1130 } 1131 nir_pop_loop(nb, NULL); 1132 1133 finish_isel_test(); 1134 END_TEST 1135 1136 /** 1137 * if (divergent) { 1138 * } else { 1139 * } 1140 * a = phi(undef, undef); 1141 * } 1142 */ 1143 BEGIN_TEST(isel.cf.divergent_if_undef.both) 1144 if (!setup_nir_cs(GFX11)) 1145 return; 1146 1147 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 1)); 1148 nir_pop_if(nb, NULL); 1149 //>> BB6 1150 //! /* logical preds: BB1, BB4, / linear preds: BB4, BB5, / kind: uniform, top-level, merge, */ 1151 //! s1: %4 = p_linear_phi s1: undef, s1: undef 1152 nir_unit_test_amd(nb, nir_if_phi(nb, nir_undef(nb, 1, 32), nir_undef(nb, 1, 32)), .base = 0); 1153 1154 finish_isel_test(); 1155 END_TEST 1156 1157 /* 1158 * if (uniform) { 1159 * terminate_if 1160 * } 1161 */ 1162 BEGIN_TEST(isel.cf.empty_exec.uniform_if) 1163 if (!setup_nir_cs(GFX11)) 1164 return; 1165 1166 //>> BB0 1167 //>> s2: %_ = p_unit_test 0 1168 //>> p_cbranch_z %_:scc 1169 nir_push_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base = 0)); 1170 { 1171 //>> BB1 1172 //>> s2: %_ = p_unit_test 1 1173 //>> p_discard_if %_ 1174 //>> p_unit_test 2, %_ 1175 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 1)); 1176 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 2); 1177 } 1178 nir_pop_if(nb, NULL); 1179 //>> BB3 1180 //! /* logical preds: BB1, BB2, / linear preds: BB1, BB2, / kind: uniform, top-level, */ 1181 1182 //>> p_unit_test 3, %_ 1183 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 3); 1184 1185 finish_isel_test(); 1186 END_TEST 1187 1188 /* 1189 * if (divergent) { 1190 * terminate_if 1191 * //potentially empty 1192 * if (divergent) { 1193 * terminate_if 1194 * //potentially empty 1195 * } else { 1196 * terminate_if 1197 * //potentially empty 1198 * } 1199 * //potentially empty 1200 * } 1201 */ 1202 BEGIN_TEST(isel.cf.empty_exec.divergent_if) 1203 if (!setup_nir_cs(GFX11)) 1204 return; 1205 1206 //>> BB0 1207 //>> s2: %_ = p_unit_test 0 1208 //>> p_cbranch_z %_ 1209 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 0)); 1210 { 1211 //>> BB1 1212 //>> s2: %_ = p_unit_test 1 1213 //>> p_discard_if %_ 1214 //>> p_cbranch_z %0:exec rarely_taken 1215 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 1)); 1216 1217 //>> p_unit_test 2, %_ 1218 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 2); 1219 1220 //>> s2: %_ = p_unit_test 3 1221 //>> p_cbranch_z %_ 1222 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 3)); 1223 { 1224 //>> p_unit_test 4, %_ 1225 //>> s2: %_ = p_unit_test 5 1226 //>> p_discard_if %_ 1227 //>> p_cbranch_z %0:exec rarely_taken 1228 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 4); 1229 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 5)); 1230 1231 //>> p_unit_test 6, %_ 1232 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 6); 1233 } 1234 nir_push_else(nb, NULL); 1235 { 1236 //>> p_unit_test 7, %_ 1237 //>> s2: %_ = p_unit_test 8 1238 //>> p_discard_if %_ 1239 //>> p_cbranch_z %0:exec rarely_taken 1240 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 7); 1241 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 8)); 1242 1243 //>> p_unit_test 9, %_ 1244 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 9); 1245 } 1246 nir_pop_if(nb, NULL); 1247 //>> BB14 1248 //! /* logical preds: BB6, BB12, / linear preds: BB12, BB13, / kind: uniform, merge, */ 1249 //>> BB15 1250 //>> /* logical preds: / linear preds: BB1, / kind: uniform, */ 1251 //>> BB16 1252 //! /* logical preds: BB14, / linear preds: BB14, BB15, / kind: uniform, */ 1253 //>> p_cbranch_z %0:exec rarely_taken 1254 1255 //>> p_unit_test 10, %_ 1256 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 10); 1257 } 1258 nir_pop_if(nb, NULL); 1259 1260 //>> BB24 1261 //! /* logical preds: BB19, BB22, / linear preds: BB22, BB23, / kind: uniform, top-level, merge, */ 1262 //! p_logical_start 1263 //! p_unit_test 11, %_ 1264 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 11); 1265 1266 finish_isel_test(); 1267 END_TEST 1268 1269 /* 1270 * loop { 1271 * terminate_if 1272 * //potentially empty 1273 * } 1274 */ 1275 BEGIN_TEST(isel.cf.empty_exec.loop_terminate) 1276 if (!setup_nir_cs(GFX11)) 1277 return; 1278 1279 nir_push_loop(nb); 1280 { 1281 nir_break_if(nb, nir_imm_false(nb)); 1282 1283 //>> BB4 1284 //>> p_unit_test 0, %_ 1285 //>> s2: %_ = p_unit_test 1 1286 //>> p_discard_if %_ 1287 //>> p_cbranch_z %0:exec rarely_taken 1288 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 0); 1289 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 1)); 1290 1291 //>> BB5 1292 //>> p_unit_test 2, %_ 1293 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 2); 1294 1295 //>> BB7 1296 //! /* logical preds: BB5, / linear preds: BB5, BB6, / kind: uniform, continue_or_break, */ 1297 } 1298 nir_pop_loop(nb, NULL); 1299 1300 //>> BB10 1301 //! /* logical preds: BB2, / linear preds: BB2, BB8, / kind: uniform, top-level, loop-exit, */ 1302 //! p_logical_start 1303 //! p_unit_test 3, %_ 1304 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 3); 1305 1306 finish_isel_test(); 1307 END_TEST 1308 1309 /* 1310 * loop { 1311 * if (divergent) { 1312 * if (divergent) { 1313 * break 1314 * } 1315 * //potentially empty 1316 * } 1317 * } 1318 */ 1319 BEGIN_TEST(isel.cf.empty_exec.loop_break) 1320 if (!setup_nir_cs(GFX11)) 1321 return; 1322 1323 nir_push_loop(nb); 1324 { 1325 //>> BB1 1326 //>> p_unit_test 0, %_ 1327 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 0); 1328 1329 //>> s2: %_ = p_unit_test 1 1330 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 1)); 1331 { 1332 //>> BB2 1333 //>> s2: %_ = p_unit_test 2 1334 //>> BB3 1335 //! /* logical preds: BB2, / linear preds: BB2, / kind: break, */ 1336 nir_break_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 2)); 1337 //>> BB10 1338 //! /* logical preds: BB8, / linear preds: BB8, BB9, / kind: uniform, merge, */ 1339 1340 //>> p_cbranch_z %0:exec rarely_taken 1341 //>> BB11 1342 //>> p_unit_test 3, %_ 1343 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 3); 1344 } 1345 nir_pop_if(nb, NULL); 1346 //>> BB18 1347 //! /* logical preds: BB13, BB16, / linear preds: BB16, BB17, / kind: uniform, continue, merge, */ 1348 //! p_logical_start 1349 1350 //! p_unit_test 4, %_ 1351 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 4); 1352 } 1353 nir_pop_loop(nb, NULL); 1354 //>> BB19 1355 //! /* logical preds: BB3, / linear preds: BB4, / kind: uniform, top-level, loop-exit, */ 1356 //! p_logical_start 1357 1358 //! p_unit_test 5, %_ 1359 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 5); 1360 1361 finish_isel_test(); 1362 END_TEST 1363 1364 /* 1365 * loop { 1366 * if (divergent) { 1367 * if (divergent) { 1368 * continue 1369 * } 1370 * //potentially empty 1371 * } 1372 * } 1373 */ 1374 BEGIN_TEST(isel.cf.empty_exec.loop_continue) 1375 if (!setup_nir_cs(GFX11)) 1376 return; 1377 1378 nir_push_loop(nb); 1379 { 1380 nir_break_if(nb, nir_imm_false(nb)); 1381 1382 //>> BB4 1383 //>> p_unit_test 0, %_ 1384 //>> s2: %_ = p_unit_test 1 1385 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 0); 1386 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 1)); 1387 { 1388 //>> BB5 1389 //>> s2: %_ = p_unit_test 2 1390 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 2)); 1391 { 1392 //>> BB6 1393 //>> /* logical preds: BB5, / linear preds: BB5, / kind: continue, */ 1394 nir_jump(nb, nir_jump_continue); 1395 } 1396 nir_pop_if(nb, NULL); 1397 //>> BB13 1398 //! /* logical preds: BB11, / linear preds: BB11, BB12, / kind: uniform, merge, */ 1399 1400 //>> p_cbranch_z %0:exec rarely_taken 1401 //>> BB14 1402 //>> p_unit_test 3, %_ 1403 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 3); 1404 } 1405 nir_pop_if(nb, NULL); 1406 //>> BB21 1407 //! /* logical preds: BB16, BB19, / linear preds: BB19, BB20, / kind: uniform, continue, merge, */ 1408 //! p_logical_start 1409 1410 //! p_unit_test 4, %_ 1411 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 4); 1412 } 1413 nir_pop_loop(nb, NULL); 1414 //>> BB22 1415 //! /* logical preds: BB2, / linear preds: BB2, / kind: uniform, top-level, loop-exit, */ 1416 //! p_logical_start 1417 1418 //! p_unit_test 5, %_ 1419 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 5); 1420 1421 finish_isel_test(); 1422 END_TEST 1423 1424 /* 1425 * loop { 1426 * if (divergent) { 1427 * continue 1428 * } 1429 * if (divergent) { 1430 * break 1431 * } 1432 * //potentially empty 1433 * } 1434 */ 1435 BEGIN_TEST(isel.cf.empty_exec.loop_continue_then_break) 1436 if (!setup_nir_cs(GFX11)) 1437 return; 1438 1439 nir_push_loop(nb); 1440 { 1441 //>> BB1 1442 //! /* logical preds: BB0, BB2, BB20, / linear preds: BB0, BB3, BB20, / kind: loop-header, branch, */ 1443 //>> p_unit_test 0, %_ 1444 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 0); 1445 1446 //>> s2: %_ = p_unit_test 1 1447 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 1)); 1448 { 1449 //>> BB2 1450 //! /* logical preds: BB1, / linear preds: BB1, / kind: continue, */ 1451 nir_jump(nb, nir_jump_continue); 1452 } 1453 nir_pop_if(nb, NULL); 1454 1455 //>> BB9 1456 //! /* logical preds: BB7, / linear preds: BB7, BB8, / kind: branch, merge, */ 1457 //>> p_unit_test 2, %_ 1458 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 2); 1459 1460 //>> s2: %_ = p_unit_test 3 1461 //>> BB10 1462 //! /* logical preds: BB9, / linear preds: BB9, / kind: break, */ 1463 nir_break_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 3)); 1464 //>> BB17 1465 //! /* logical preds: BB15, / linear preds: BB15, BB16, / kind: uniform, merge, */ 1466 //>> p_cbranch_z %0:exec rarely_taken 1467 1468 //>> BB18 1469 //! /* logical preds: BB17, / linear preds: BB17, / kind: uniform, */ 1470 //>> p_unit_test 4, %_ 1471 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 4); 1472 1473 //>> BB20 1474 //! /* logical preds: BB18, / linear preds: BB18, BB19, / kind: uniform, continue, */ 1475 } 1476 nir_pop_loop(nb, NULL); 1477 //>> BB21 1478 //! /* logical preds: BB10, / linear preds: BB11, / kind: uniform, top-level, loop-exit, */ 1479 //! p_logical_start 1480 1481 //! p_unit_test 5, %_ 1482 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 5); 1483 1484 finish_isel_test(); 1485 END_TEST 1486 1487 /* 1488 * if (divergent) { 1489 * terminate_if 1490 * //potentially empty 1491 * if (uniform) { 1492 * } 1493 * //potentially empty 1494 * } 1495 */ 1496 BEGIN_TEST(isel.cf.empty_exec.terminate_then_uniform_if) 1497 if (!setup_nir_cs(GFX11)) 1498 return; 1499 1500 //>> BB0 1501 //>> s2: %_ = p_unit_test 0 1502 //>> p_cbranch_z %_ 1503 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 0)); 1504 { 1505 //>> BB1 1506 //>> s2: %_ = p_unit_test 1 1507 //>> s2: %_ = p_unit_test 2 1508 //>> p_discard_if %_ 1509 nir_def* cond = nir_unit_test_uniform_amd(nb, 1, 1, .base = 1); 1510 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 2)); 1511 //>> p_cbranch_z %0:exec rarely_taken 1512 1513 //>> p_cbranch_z %_:scc 1514 nir_push_if(nb, cond); 1515 { 1516 //>> p_unit_test 3, %2 1517 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 3); 1518 } 1519 nir_pop_if(nb, NULL); 1520 1521 //>> p_unit_test 4, %1 1522 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 4); 1523 1524 //>> BB6 1525 //! /* logical preds: / linear preds: BB1, / kind: uniform, */ 1526 } 1527 nir_pop_if(nb, NULL); 1528 1529 finish_isel_test(); 1530 END_TEST 1531 1532 /* 1533 * if (divergent) { 1534 * terminate_if 1535 * if (divergent) { 1536 * } 1537 * //potentially empty 1538 * } 1539 */ 1540 BEGIN_TEST(isel.cf.empty_exec.terminate_then_divergent_if) 1541 if (!setup_nir_cs(GFX11)) 1542 return; 1543 1544 //>> BB0 1545 //>> s2: %_ = p_unit_test 0 1546 //>> p_cbranch_z %_ 1547 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 0)); 1548 { 1549 //>> BB1 1550 //>> s2: %_ = p_unit_test 1 1551 //>> s2: %_ = p_unit_test 2 1552 //>> p_discard_if %_ 1553 nir_def* cond = nir_unit_test_divergent_amd(nb, 1, 1, .base = 1); 1554 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 2)); 1555 //>> p_cbranch_z %0:exec rarely_taken 1556 1557 //>> p_cbranch_z %_ 1558 nir_push_if(nb, cond); 1559 { 1560 //>> BB3 1561 //! /* logical preds: BB2, / linear preds: BB2, / kind: uniform, */ 1562 //! p_logical_start 1563 //! p_unit_test 3, %_ 1564 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 3); 1565 } 1566 nir_pop_if(nb, NULL); 1567 1568 //>> p_unit_test 4, %1 1569 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 4); 1570 1571 //>> BB9 1572 //! /* logical preds: / linear preds: BB1, / kind: uniform, */ 1573 } 1574 nir_pop_if(nb, NULL); 1575 1576 finish_isel_test(); 1577 END_TEST 1578 1579 /* 1580 * if (divergent) { 1581 * terminate_if 1582 * //potentially empty 1583 * loop { 1584 * } 1585 * //potentially empty 1586 * } 1587 */ 1588 BEGIN_TEST(isel.cf.empty_exec.terminate_then_loop) 1589 if (!setup_nir_cs(GFX11)) 1590 return; 1591 1592 //>> BB0 1593 //>> s2: %_ = p_unit_test 0 1594 //>> p_cbranch_z %_ 1595 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 0)); 1596 { 1597 //>> BB1 1598 //>> s2: %_ = p_unit_test 1 1599 //>> p_discard_if %_ 1600 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 1)); 1601 //>> p_cbranch_z %0:exec rarely_taken 1602 1603 //>> BB2 1604 //! /* logical preds: BB1, / linear preds: BB1, / kind: uniform, loop-preheader, */ 1605 nir_push_loop(nb); 1606 { 1607 nir_break_if(nb, nir_imm_false(nb)); 1608 1609 //>> BB6 1610 //! /* logical preds: BB5, / linear preds: BB5, / kind: uniform, continue, */ 1611 //>> p_unit_test 2, %1 1612 nir_unit_test_amd(nb, nir_undef(nb, 1, 32), .base = 2); 1613 } 1614 nir_pop_loop(nb, NULL); 1615 //>> BB7 1616 //! /* logical preds: BB4, / linear preds: BB4, / kind: uniform, loop-exit, */ 1617 } 1618 1619 finish_isel_test(); 1620 END_TEST 1621 1622 /* 1623 * if (divergent) { 1624 * terminate_if 1625 * //potentially empty 1626 * loop { 1627 * terminate_if 1628 * //potentially empty 1629 * loop { 1630 * terminate_if 1631 * //potentially empty 1632 * val = ... 1633 * if (uniform) break 1634 * break 1635 * } 1636 * if (uniform) break 1637 * } 1638 * } 1639 * use(val) 1640 */ 1641 BEGIN_TEST(isel.cf.empty_exec.repair_ssa) 1642 if (!setup_nir_cs(GFX11)) 1643 return; 1644 1645 nir_def* val_sgpr; 1646 nir_def* val_vgpr; 1647 nir_push_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 0)); 1648 { 1649 //>> BB1 1650 //! /* logical preds: BB0, / linear preds: BB0, / kind: uniform, discard, */ 1651 //>> s2: %_ = p_unit_test 1 1652 //>> p_cbranch_z %0:exec rarely_taken 1653 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 1)); 1654 1655 nir_push_loop(nb); 1656 { 1657 //>> BB3 1658 //! /* logical preds: BB2, BB20, / linear preds: BB2, BB22, / kind: uniform, loop-header, discard, */ 1659 //>> s2: %_ = p_unit_test 2 1660 //>> p_cbranch_z %0:exec rarely_taken 1661 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 2)); 1662 1663 nir_push_loop(nb); 1664 { 1665 //>> BB5 1666 //! /* logical preds: BB4, / linear preds: BB4, / kind: uniform, loop-header, discard, */ 1667 //>> s2: %_ = p_unit_test 3 1668 //>> p_cbranch_z %0:exec rarely_taken 1669 nir_terminate_if(nb, nir_unit_test_divergent_amd(nb, 1, 1, .base = 3)); 1670 1671 //>> BB6 1672 //! /* logical preds: BB5, / linear preds: BB5, / kind: uniform, */ 1673 //>> s1: %sgpr0 = p_parallelcopy 42 1674 //>> v1: %vgpr0 = v_mbcnt_hi_u32_b32_e64 %_, %_ 1675 val_sgpr = nir_imm_int(nb, 42); 1676 val_vgpr = nir_mbcnt_amd(nb, nir_imm_intN_t(nb, UINT64_MAX, 64), nir_imm_int(nb, 0)); 1677 1678 //>> BB7 1679 //! /* logical preds: BB6, / linear preds: BB6, / kind: uniform, break, */ 1680 nir_break_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base = 4)); 1681 1682 //>> BB10 1683 //! /* logical preds: / linear preds: BB5, / kind: uniform, */ 1684 //>> BB11 1685 //! /* logical preds: BB9, / linear preds: BB9, BB10, / kind: uniform, break, */ 1686 //! s1: %sgpr1 = p_linear_phi %sgpr0, s1: undef 1687 nir_jump(nb, nir_jump_break); 1688 } 1689 nir_pop_loop(nb, NULL); 1690 //>> BB12 1691 //! /* logical preds: BB7, BB11, / linear preds: BB7, BB11, / kind: uniform, loop-exit, */ 1692 //! s1: %sgpr2 = p_linear_phi %sgpr0, %sgpr1 1693 //>> BB13 1694 //! /* logical preds: / linear preds: BB3, / kind: uniform, */ 1695 //>> BB14 1696 //! /* logical preds: BB12, / linear preds: BB12, BB13, / kind: uniform, */ 1697 //! s1: %sgpr3 = p_linear_phi %sgpr2, s1: undef 1698 //>> p_cbranch_z %0:exec rarely_taken 1699 1700 //>> BB15 1701 //! /* logical preds: BB14, / linear preds: BB14, / kind: uniform, */ 1702 //>> p_unit_test 5, %sgpr3 1703 //>> p_unit_test 6, %vgpr3 1704 //>> p_unit_test 7, %sgpr3 1705 //>> p_unit_test 8, %vgpr3 1706 nir_unit_test_amd(nb, val_sgpr, .base = 5); 1707 nir_unit_test_amd(nb, val_vgpr, .base = 6); 1708 nir_unit_test_amd(nb, val_sgpr, .base = 7); 1709 nir_unit_test_amd(nb, val_vgpr, .base = 8); 1710 1711 //>> BB16 1712 //! /* logical preds: BB15, / linear preds: BB15, / kind: uniform, break, */ 1713 nir_break_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base = 9)); 1714 //>> BB20 1715 //! /* logical preds: BB18, / linear preds: BB18, BB19, / kind: uniform, continue_or_break, */ 1716 } 1717 nir_pop_loop(nb, NULL); 1718 //>> BB23 1719 //! /* logical preds: BB16, / linear preds: BB16, BB21, / kind: uniform, loop-exit, */ 1720 //>> BB24 1721 //! /* logical preds: / linear preds: BB1, / kind: uniform, */ 1722 //>> BB25 1723 //! /* logical preds: BB23, / linear preds: BB23, BB24, / kind: uniform, */ 1724 //! s1: %sgpr4 = p_linear_phi %sgpr3, s1: undef 1725 } 1726 nir_pop_if(nb, NULL); 1727 //>> BB27 1728 //! /* logical preds: / linear preds: BB25, BB26, / kind: invert, */ 1729 //! s1: %sgpr5 = p_linear_phi %sgpr4, s1: undef 1730 //>> BB30 1731 //! /* logical preds: BB25, BB28, / linear preds: BB28, BB29, / kind: uniform, top-level, merge, */ 1732 //! v1: %vgpr = p_phi %vgpr0, v1: undef 1733 //! s1: %sgpr = p_linear_phi %sgpr5, %sgpr5 1734 val_sgpr = nir_if_phi(nb, val_sgpr, nir_undef(nb, 1, 32)); 1735 val_vgpr = nir_if_phi(nb, val_vgpr, nir_undef(nb, 1, 32)); 1736 1737 //>> p_unit_test 10, %sgpr 1738 //>> p_unit_test 11, %vgpr 1739 nir_unit_test_amd(nb, val_sgpr, .base = 10); 1740 nir_unit_test_amd(nb, val_vgpr, .base = 11); 1741 1742 finish_isel_test(); 1743 END_TEST 1744 1745 /* 1746 * loop { 1747 * if (uniform) { 1748 * terminate_if 1749 * //potentially empty 1750 * continue 1751 * } 1752 * //potentially empty 1753 * break 1754 * } 1755 */ 1756 BEGIN_TEST(isel.cf.empty_exec.loop_uniform_continue) 1757 if (!setup_nir_cs(GFX11)) 1758 return; 1759 1760 nir_push_loop(nb); 1761 { 1762 //>> BB1 1763 //! /* logical preds: BB0, BB2, / linear preds: BB0, BB3, / kind: uniform, loop-header, */ 1764 1765 nir_push_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base = 0)); 1766 { 1767 //>> BB2 1768 //! /* logical preds: BB1, / linear preds: BB1, / kind: continue, discard, */ 1769 nir_terminate_if(nb, nir_unit_test_uniform_amd(nb, 1, 1, .base = 1)); 1770 nir_jump(nb, nir_jump_continue); 1771 } 1772 nir_pop_if(nb, NULL); 1773 1774 //>> BB6 1775 //! /* logical preds: BB5, / linear preds: BB4, BB5, / kind: uniform, break, */ 1776 nir_jump(nb, nir_jump_break); 1777 } 1778 nir_pop_loop(nb, NULL); 1779 1780 finish_isel_test(); 1781 END_TEST 1782