From b939de025ddcba673347086dff460edac26ff9c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Briano?= Date: Fri, 18 Apr 2025 16:46:04 -0700 Subject: [PATCH] brw: make HALT instruction act as barrier in new CSE pass This brings back c9e33e5cbf6 ("intel/fs/cse: Make HALT instruction act as CSE barrier."), from the old CSE pass into the new one. Fixes new CTS test: dEQP-VK.subgroups.shader_quad_control.terminated_invocation Fixes: 9690bd369d5 ("intel/brw: Delete old local common subexpression elimination pass") Reviewed-by: Kenneth Graunke Reviewed-by: Ian Romanick Part-of: (cherry picked from commit 29d7b90cfcb67ecc2ff3e422dd7b38898abb1bbe) --- .pick_status.json | 2 +- src/intel/compiler/brw_opt_cse.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index d216810b405..dadc204dfb6 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -54,7 +54,7 @@ "description": "brw: make HALT instruction act as barrier in new CSE pass", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "9690bd369d5a6739142eeb23f92d34429b75855d", "notes": null diff --git a/src/intel/compiler/brw_opt_cse.cpp b/src/intel/compiler/brw_opt_cse.cpp index 30a3b174b8b..f3ef8956f5a 100644 --- a/src/intel/compiler/brw_opt_cse.cpp +++ b/src/intel/compiler/brw_opt_cse.cpp @@ -418,6 +418,24 @@ brw_opt_cse_defs(brw_shader &s) last_flag_write = last; last = inst; + /* Discard jumps aren't represented in the CFG unfortunately, so we need + * to make sure that they behave as a CSE barrier, since we lack global + * dataflow information. This is particularly likely to cause problems + * with instructions dependent on the current execution mask like + * SHADER_OPCODE_FIND_LIVE_CHANNEL. + */ + if (inst->opcode == BRW_OPCODE_HALT || + inst->opcode == SHADER_OPCODE_HALT_TARGET) { + /* Treat each side of the HALT separately for local_only + * expressions as it's altering the channel enables. + */ + set_foreach(set, e) { + brw_inst *match = (brw_inst *) e->key; + if (match->block == block && local_only(match)) + _mesa_set_remove(set, e); + } + } + if (inst->dst.is_null()) { bool ignored; if (last_flag_write && !inst->writes_accumulator &&