From f77bbc92364e9bcf82f892fdacbc090822b358d8 Mon Sep 17 00:00:00 2001 From: Boris Brezillon Date: Sun, 18 Oct 2020 21:52:25 +0200 Subject: [PATCH] pan/bi: Lower {i,u}{min,max} instructions There's no native integer min/min instruction on Bifrost, lower those to a cmp+bcsel pair. Signed-off-by: Boris Brezillon Reviewed-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bifrost_nir_algebraic.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/panfrost/bifrost/bifrost_nir_algebraic.py b/src/panfrost/bifrost/bifrost_nir_algebraic.py index 974bdf2c899..b0aa98316c4 100644 --- a/src/panfrost/bifrost/bifrost_nir_algebraic.py +++ b/src/panfrost/bifrost/bifrost_nir_algebraic.py @@ -42,6 +42,14 @@ for isz in ('8', '16', '32'): for osz in ('16', '32', '64'): algebraic_late += [(('b2f' + osz, 'a@' + isz), ('b' + isz + 'csel', a, 1.0, 0.0))] +# There's no native integer min/max instruction, lower those to cmp+bcsel +for sz in ('8', '16', '32'): + for t in ('i', 'u'): + algebraic_late += [ + ((t + 'min', 'a@' + sz, 'b@' + sz), ('b' + sz + 'csel', (t + 'lt' + sz, a, b), a, b)), + ((t + 'max', 'a@' + sz, 'b@' + sz), ('b' + sz + 'csel', (t + 'lt' + sz, b, a), a, b)) + ] + # Midgard is able to type convert down by only one "step" per instruction; if # NIR wants more than one step, we need to break up into multiple instructions