[Mesa-dev] [PATCH 24/24] RFC nir/algebraic: Optimize open-coded nir_binop_bfm

Ian Romanick idr at freedesktop.org
Wed Jun 29 21:04:31 UTC 2016


From: Ian Romanick <ian.d.romanick at intel.com>

BFM is (((1u << a) - 1) << b).  Recognize a couple patterns that look
like this, and replace them with BFM.

NOTE: Using lower_bitfield_insert is definitely not the right way to
flag this optimization... so, I'm looking for some advice as to what the
right way is.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/compiler/nir/nir_opt_algebraic.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index e3d83d4..06ebdbf 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -315,6 +315,11 @@ optimizations = [
               ('bfi', ('bfm', 'bits', 'offset'), 'insert', 'base')),
     'options->lower_bitfield_insert'),
 
+   (('ishl at 32', ('iadd', ('ishl', 1, a), -1), b), ('bfm', a, b),
+    'options->lower_bitfield_insert'),
+   (('iadd at 32', ('ishl', 1, a), -1), ('bfm', a, 0),
+    'options->lower_bitfield_insert'),
+
    (('ibitfield_extract', 'value', 'offset', 'bits'),
     ('bcsel', ('ilt', 31, 'bits'), 'value',
               ('ibfe', 'value', 'offset', 'bits')),
-- 
2.5.5



More information about the mesa-dev mailing list