Mesa (master): nir: Fix lowering of bitfield_insert to shifts.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jun 28 23:41:57 UTC 2019


Module: Mesa
Branch: master
Commit: 8fd8964302af652f7de14923111ca9b15b8d2b48
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=8fd8964302af652f7de14923111ca9b15b8d2b48

Author: Eric Anholt <eric at anholt.net>
Date:   Thu Jun 27 14:29:37 2019 -0700

nir: Fix lowering of bitfield_insert to shifts.

The bfi/bfm behavior change replaced the bfi/bfm usage in
lower_bitfield_insert_to_shifts with actual shifts like the name says,
but it failed to handle the offset=0, bits==32 case in the new
lowering.

v2: Use 31 < bits instead of bits == 32, to get the 31 < (iand bits,
    31) -> false optimization.

Fixes regressions in dEQP-GLES31.*bitfield_insert* on freedreno.

Fixes: 165b7f3a4487 ("nir: define behavior of nir_op_bfm and nir_op_u/ibfe according to SM5 spec.")
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>

---

 src/compiler/nir/nir_opt_algebraic.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 8b786887052..4fd9a93a22a 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -795,9 +795,11 @@ optimizations.extend([
 
    # Alternative lowering that doesn't rely on bfi.
    (('bitfield_insert', 'base', 'insert', 'offset', 'bits'),
-    ('ior',
-    ('iand', 'base', ('inot', ('ishl', ('isub', ('ishl', 1, 'bits'), 1), 'offset'))),
-    ('iand', ('ishl', 'insert', 'offset'), ('ishl', ('isub', ('ishl', 1, 'bits'), 1), 'offset'))),
+    ('bcsel', ('ult', 31, 'bits'),
+     'insert',
+    (('ior',
+     ('iand', 'base', ('inot', ('ishl', ('isub', ('ishl', 1, 'bits'), 1), 'offset'))),
+     ('iand', ('ishl', 'insert', 'offset'), ('ishl', ('isub', ('ishl', 1, 'bits'), 1), 'offset'))))),
     'options->lower_bitfield_insert_to_shifts'),
 
    # Alternative lowering that uses bitfield_select.




More information about the mesa-commit mailing list