From 50f2cd73668ab1d5cc9c24bfd7222574af5c160a Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 25 Feb 2025 09:06:40 -0800 Subject: [PATCH] brw/dce: Don't generate more NULL destinations after brw_lower_3src_null_dest Later commits will call DCE after lowering has been performed. Creating more things that would need lowering is problematic. No shader-db or fossil-db changes on any Intel platform. Reviewed-by: Caio Oliveira Part-of: --- .../compiler/brw/brw_opt_dead_code_eliminate.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/intel/compiler/brw/brw_opt_dead_code_eliminate.cpp b/src/intel/compiler/brw/brw_opt_dead_code_eliminate.cpp index 0def547f256..77ddb0878f7 100644 --- a/src/intel/compiler/brw/brw_opt_dead_code_eliminate.cpp +++ b/src/intel/compiler/brw/brw_opt_dead_code_eliminate.cpp @@ -51,12 +51,18 @@ can_eliminate(const intel_device_info *devinfo, const brw_inst *inst, * Is it safe to omit the write, making the destination ARF null? */ static bool -can_omit_write(const brw_inst *inst) +can_omit_write(const brw_compiler *compiler, const brw_inst *inst, bool late) { switch (inst->opcode) { case SHADER_OPCODE_MEMORY_ATOMIC_LOGICAL: return true; default: + /* Dead code elimination that occurs once after brw_lower_3src_null_dest + * should not generate more NULL destinations. + */ + if (inst->is_3src(compiler) && late) + return false; + /* We can eliminate the destination write for ordinary instructions, * but not most SENDs. */ @@ -100,6 +106,7 @@ bool brw_opt_dead_code_eliminate(brw_shader &s) { const intel_device_info *devinfo = s.devinfo; + const bool late = s.phase >= BRW_SHADER_PHASE_AFTER_LATE_LOWERING; bool progress = false; @@ -123,7 +130,8 @@ brw_opt_dead_code_eliminate(brw_shader &s) result_live |= BITSET_TEST(live, var + i); if (!result_live && - (can_omit_write(inst) || can_eliminate(devinfo, inst, flag_live))) { + (can_omit_write(s.compiler, inst, late) || + can_eliminate(devinfo, inst, flag_live))) { inst->dst = brw_reg(spread(retype(brw_null_reg(), inst->dst.type), inst->dst.stride)); progress = true;