microsoft/compiler: Fix codegen when a loop ends in a jump
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/7792 Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20255>
This commit is contained in:
parent
16c4c1a549
commit
733264bd7c
1 changed files with 9 additions and 3 deletions
|
|
@ -5342,9 +5342,10 @@ static bool
|
|||
emit_loop(struct ntd_context *ctx, nir_loop *loop)
|
||||
{
|
||||
nir_block *first_block = nir_loop_first_block(loop);
|
||||
nir_block *last_block = nir_loop_last_block(loop);
|
||||
|
||||
assert(nir_loop_last_block(loop)->successors[0]);
|
||||
assert(!nir_loop_last_block(loop)->successors[1]);
|
||||
assert(last_block->successors[0]);
|
||||
assert(!last_block->successors[1]);
|
||||
|
||||
if (!emit_branch(ctx, first_block->index))
|
||||
return false;
|
||||
|
|
@ -5352,7 +5353,12 @@ emit_loop(struct ntd_context *ctx, nir_loop *loop)
|
|||
if (!emit_cf_list(ctx, &loop->body))
|
||||
return false;
|
||||
|
||||
if (!emit_branch(ctx, first_block->index))
|
||||
/* If the loop's last block doesn't explicitly jump somewhere, then there's
|
||||
* an implicit continue that should take it back to the first loop block
|
||||
*/
|
||||
nir_instr *last_instr = nir_block_last_instr(last_block);
|
||||
if ((!last_instr || last_instr->type != nir_instr_type_jump) &&
|
||||
!emit_branch(ctx, first_block->index))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue