if the last instruction in a loop's body terminates a block, e.g., from
a nested loop with a jump as its final instruction, then no block will
have been started when returning to the original loop, and there's no need
to emit a branch
fixes shaders@glsl-vs-continue-in-switch-in-do-while
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5852>
ctx->loop_break = save_break;
ctx->loop_cont = save_cont;
- branch(ctx, cont_id);
+ /* loop->body may have already ended our block */
+ if (ctx->block_started)
+ branch(ctx, cont_id);
start_block(ctx, cont_id);
branch(ctx, header_id);