From ffae24bfe250de518da9586f124b81b58df1494c Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 14 Apr 2026 05:51:30 -0400 Subject: [PATCH] panvk: Implement bitfield_select Reviewed-by: Christoph Pillmayer Reviewed-by: Lorenzo Rossi Part-of: --- src/panfrost/compiler/bifrost/bifrost_compile.c | 10 ++++++++++ src/panfrost/compiler/bifrost/bifrost_compile.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/panfrost/compiler/bifrost/bifrost_compile.c b/src/panfrost/compiler/bifrost/bifrost_compile.c index 1e917d90c9f..58c35e9667d 100644 --- a/src/panfrost/compiler/bifrost/bifrost_compile.c +++ b/src/panfrost/compiler/bifrost/bifrost_compile.c @@ -3530,6 +3530,16 @@ bi_emit_alu(bi_builder *b, nir_alu_instr *instr) bi_bitrev_i32_to(b, dst, s0); break; + case nir_op_bitfield_select: + /* Bifrost doesn't have MUX.v4i8.bit but that's okay because MUX.v4i8 + * can't swizzle on Bifrost anyway so we can just use MUX.i32. + */ + if (b->shader->arch < 9 && sz == 8) + bi_mux_i32_to(b, dst, s1, s2, s0, BI_MUX_BIT); + else + bi_mux_to(b, sz, dst, s1, s2, s0, BI_MUX_BIT); + break; + case nir_op_ufind_msb: { bi_index clz = bi_clz(b, src_sz, s0, false); diff --git a/src/panfrost/compiler/bifrost/bifrost_compile.h b/src/panfrost/compiler/bifrost/bifrost_compile.h index e5085742dd5..71eb9e9db44 100644 --- a/src/panfrost/compiler/bifrost/bifrost_compile.h +++ b/src/panfrost/compiler/bifrost/bifrost_compile.h @@ -99,6 +99,7 @@ bool valhall_can_merge_workgroups(nir_shader *nir); .lower_bitfield_extract8 = true, \ .lower_bitfield_extract16 = true, \ .lower_insert_byte = true, \ + .has_bitfield_select = true, \ \ .lower_pack_64_4x16 = true, \ .lower_pack_half_2x16 = true, \