From: Ian Romanick <ian.d.roman...@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.roman...@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@32', ('iadd', ('ishl', 1, a), -1), b), ('bfm', a, b),
+    'options->lower_bitfield_insert'),
+   (('iadd@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

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to