From dff1e8ae28b4078f47b0e9b11df850855d4388ba Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 11 Dec 2025 18:37:00 -0800 Subject: [PATCH] brw: Handle scalars and swizzles correctly in is_const_zero v2: Massive simplification based on feedback from Ken. Fixes: 96cde9cc01d ("intel/fs: Emit better code for bfi(..., 0)") Reviewed-by: Kenneth Graunke Part-of: --- src/intel/compiler/brw/brw_from_nir.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/intel/compiler/brw/brw_from_nir.cpp b/src/intel/compiler/brw/brw_from_nir.cpp index 37e75ccd4e6..9477a468a1b 100644 --- a/src/intel/compiler/brw/brw_from_nir.cpp +++ b/src/intel/compiler/brw/brw_from_nir.cpp @@ -797,9 +797,9 @@ try_emit_b2fi_of_inot(nir_to_brw_state &ntb, const brw_builder &bld, } static bool -is_const_zero(const nir_src &src) +is_const_zero(const nir_alu_src &src) { - return nir_src_is_const(src) && nir_src_as_int(src) == 0; + return nir_src_is_const(src.src) && nir_alu_src_as_uint(src) == 0; } static void @@ -1554,7 +1554,7 @@ brw_from_nir_emit_alu(nir_to_brw_state &ntb, nir_alu_instr *instr, * either 0 or src0. Replacing the 0 with another value can eliminate a * temporary register. */ - if (is_const_zero(instr->src[2].src)) + if (is_const_zero(instr->src[2])) bld.BFI2(result, op[0], op[1], op[0]); else bld.BFI2(result, op[0], op[1], op[2]);