From a085877c5683b76d1ffa784a15710ebdca40a22f Mon Sep 17 00:00:00 2001 From: Iago Toral Quiroga Date: Wed, 24 Jan 2024 09:32:40 +0100 Subject: [PATCH] broadcom/compiler: fix incorrect flags setup in non-uniform if path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the ELSE block is cheap then we don't emit the branch instruction but we still want to generate the flags, since these are setting the flags for the THEN block too. Fixes: e401add741 ("broadcom/compiler: skip jumps in non-uniform if/then when block cost is small") Reviewed-by: Alejandro PiƱeiro Cc: mesa-stable Part-of: (cherry picked from commit 29d4924e5e5b2460d442012e05c210c03b0747f7) --- .pick_status.json | 2 +- src/broadcom/compiler/nir_to_vir.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 91a94b2e576..a6dcd529203 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -344,7 +344,7 @@ "description": "broadcom/compiler: fix incorrect flags setup in non-uniform if path", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "e401add741f33d113fe1496298e35ad00ce6a878", "notes": null diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c index a4b904f9d80..2f1723d0678 100644 --- a/src/broadcom/compiler/nir_to_vir.c +++ b/src/broadcom/compiler/nir_to_vir.c @@ -3957,19 +3957,27 @@ ntq_emit_nonuniform_if(struct v3d_compile *c, nir_if *if_stmt) c->execute, vir_uniform_ui(c, else_block->index)); + /* Set the flags for taking the THEN block */ + vir_set_pf(c, vir_MOV_dest(c, vir_nop_reg(), c->execute), + V3D_QPU_PF_PUSHZ); + /* Jump to ELSE if nothing is active for THEN (unless THEN block is * so small it won't pay off), otherwise fall through. */ bool is_cheap = exec_list_is_singular(&if_stmt->then_list) && is_cheap_block(nir_if_first_then_block(if_stmt)); if (!is_cheap) { - vir_set_pf(c, vir_MOV_dest(c, vir_nop_reg(), c->execute), V3D_QPU_PF_PUSHZ); vir_BRANCH(c, V3D_QPU_BRANCH_COND_ALLNA); vir_link_blocks(c->cur_block, else_block); } vir_link_blocks(c->cur_block, then_block); - /* Process the THEN block. */ + /* Process the THEN block. + * + * Notice we don't call ntq_activate_execute_for_block here on purpose: + * c->execute is already set up to be 0 for lanes that must take the + * THEN block. + */ vir_set_emit_block(c, then_block); ntq_emit_cf_list(c, &if_stmt->then_list);