From 27c1b2e7902490fec13e9cdc971a5456790af4e7 Mon Sep 17 00:00:00 2001 From: Natalie Vock Date: Mon, 20 Oct 2025 15:07:05 +0200 Subject: [PATCH] nir/lower_shader_calls: Repair SSA after wrap_instrs Wrapping jump instructions that are located inside ifs can break SSA invariants because the else block no longer dominates the merge block. Repair the SSA to make the validator happy again. Cc: mesa-stable Part-of: (cherry picked from commit 50e65dac794511fb392fd9103f50c553d69a56d2) --- .pick_status.json | 2 +- src/compiler/nir/nir_lower_shader_calls.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index fba9ca327a9..324836ab1f5 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1294,7 +1294,7 @@ "description": "nir/lower_shader_calls: Repair SSA after wrap_instrs", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/compiler/nir/nir_lower_shader_calls.c b/src/compiler/nir/nir_lower_shader_calls.c index 1c4e29cd9cd..35aa781da5a 100644 --- a/src/compiler/nir/nir_lower_shader_calls.c +++ b/src/compiler/nir/nir_lower_shader_calls.c @@ -1228,8 +1228,16 @@ wrap_instr(nir_builder *b, nir_instr *instr, void *data) static bool wrap_instrs(nir_shader *shader, wrap_instr_callback callback) { - return nir_shader_instructions_pass(shader, wrap_instr, - nir_metadata_none, callback); + bool progress = nir_shader_instructions_pass(shader, wrap_instr, + nir_metadata_none, callback); + /* Wrapping jump instructions that are located inside ifs can break SSA + * invariants because the else block no longer dominates the merge block. + * Repair the SSA to make the validator happy again. + */ + if (progress) + nir_repair_ssa(shader); + + return progress; } static bool