From ef7095c85b82043faa8f72937bb75418228ab7a8 Mon Sep 17 00:00:00 2001 From: Mary Guillemard Date: Tue, 5 Aug 2025 11:04:58 +0000 Subject: [PATCH] pan/bi: Handle needless conversions in nir_lower_bool_to_bitsize We can end up with conversion instructions to the same type of integer with nir_lower_bool_to_bitsize so let's make bifrost_nir_lower_algebraic_late handle those cases. Signed-off-by: Mary Guillemard Acked-by: Erik Faye-Lund Reviewed-by: Eric R. Smith Part-of: --- src/panfrost/compiler/bifrost_nir_algebraic.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/panfrost/compiler/bifrost_nir_algebraic.py b/src/panfrost/compiler/bifrost_nir_algebraic.py index 3fab360ec48..47e8747b4e5 100644 --- a/src/panfrost/compiler/bifrost_nir_algebraic.py +++ b/src/panfrost/compiler/bifrost_nir_algebraic.py @@ -106,6 +106,12 @@ algebraic_late = [ (('ffract', a), ('fadd', a, ('fneg', ('ffloor', a))), 'gpu_arch >= 11'), ] +# nir_lower_bool_to_bitsize can generate needless conversions. +for bits in [8, 16, 32]: + algebraic_late += [ + ((f'i2i{bits}', f'a@{bits}'), a) + ] + # On v11+, ICMP_OR.v4u8 was removed for cond in ['ilt', 'ige', 'ieq', 'ine', 'ult', 'uge']: convert_8bit = 'u2u8'