nir/algebraic: Use unsigned comparison when lowering bitfield insert/extract
authorDaniel Schürmann <daniel.schuermann@campus.tu-berlin.de>
Thu, 2 May 2019 13:28:59 +0000 (15:28 +0200)
committerDaniel Schürmann <daniel@schuermann.dev>
Mon, 24 Jun 2019 16:42:20 +0000 (18:42 +0200)
This lets us use the optimization pattern
(('ult', 31, ('iand', b, 31)), False) to remove the
bcsel instruction for code originating in D3D shaders.

Reviewed-by: Connor Abbott <cwabbott0@gmail.com>
src/compiler/nir/nir_opt_algebraic.py

index 6e660df..0d21696 100644 (file)
@@ -782,7 +782,7 @@ optimizations.extend([
    (('usub_borrow@32', a, b), ('b2i', ('ult', a, b)), 'options->lower_usub_borrow'),
 
    (('bitfield_insert', 'base', 'insert', 'offset', 'bits'),
-    ('bcsel', ('ilt', 31, 'bits'), 'insert',
+    ('bcsel', ('ult', 31, 'bits'), 'insert',
               ('bfi', ('bfm', 'bits', 'offset'), 'insert', 'base')),
     'options->lower_bitfield_insert'),
    (('ihadd', a, b), ('iadd', ('iand', a, b), ('ishr', ('ixor', a, b), 1)), 'options->lower_hadd'),
@@ -800,7 +800,7 @@ optimizations.extend([
     'options->lower_bitfield_insert_to_shifts'),
 
    (('ibitfield_extract', 'value', 'offset', 'bits'),
-    ('bcsel', ('ilt', 31, 'bits'), 'value',
+    ('bcsel', ('ult', 31, 'bits'), 'value',
               ('ibfe', 'value', 'offset', 'bits')),
     'options->lower_bitfield_extract'),