From 7054ea6d459dd2987bc1aeb8e0030cb77fe180c0 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 9 Mar 2026 16:27:42 -0400 Subject: [PATCH] pan/bi: Be more careful about bit sizes in b2f lowering Fixes: 21bdee7bccd2 ("pan/bi: Switch to lower_bool_to_bitsize") Reviewed-by: Christoph Pillmayer (cherry picked from commit 08c437f64412f4fbdfac06bc567ce5c04231853f) Part-of: --- .pick_status.json | 2 +- src/panfrost/compiler/bifrost/bifrost_nir_algebraic.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 9a948d6f4cb..1c2c6ca5654 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -474,7 +474,7 @@ "description": "pan/bi: Be more careful about bit sizes in b2f lowering", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "21bdee7bccd2b9b4b4f3b8b2eefce0466fc4b621", "notes": null diff --git a/src/panfrost/compiler/bifrost/bifrost_nir_algebraic.py b/src/panfrost/compiler/bifrost/bifrost_nir_algebraic.py index 27d0a400a52..3a5ded6b8ce 100644 --- a/src/panfrost/compiler/bifrost/bifrost_nir_algebraic.py +++ b/src/panfrost/compiler/bifrost/bifrost_nir_algebraic.py @@ -112,9 +112,14 @@ for cond in ['ilt', 'ige', 'ieq', 'ine', 'ult', 'uge']: # automatically. Do so explicitly. (The more specific pattern must be first.) for bsz in [8, 16, 32]: for fsz in [16, 32]: + if bsz == fsz: + a_fsz = 'a' + else: + a_fsz = (f'i2i{fsz}', a) + algebraic_late += [ - ((f'b2f{fsz}', ('inot', f'a@{bsz}')), (f'b{bsz}csel', a, 0.0, 1.0)), - ((f'b2f{fsz}', f'a@{bsz}'), (f'b{bsz}csel', a, 1.0, 0.0)), + ((f'b2f{fsz}', ('inot', f'a@{bsz}')), (f'b{fsz}csel', a_fsz, 0.0, 1.0)), + ((f'b2f{fsz}', f'a@{bsz}'), (f'b{fsz}csel', a_fsz, 1.0, 0.0)), ]