V3D doesn't have opcodes for ibfe/ubfe, so we need to lower similarly to glsl/lower_instructions.cpp. --- src/compiler/nir/nir.h | 3 +++ src/compiler/nir/nir_opt_algebraic.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+)
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index ed95dbf955d8..ee1d59ffe7cd 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1879,7 +1879,10 @@ typedef struct nir_shader_compiler_options { bool lower_fsqrt; bool lower_fmod32; bool lower_fmod64; + /** Lowers ibitfield_extract/ubitfield_extract to ibfe/ubfe. */ bool lower_bitfield_extract; + /** Lowers ibitfield_extract/ubitfield_extract to bfm, compares, shifts. */ + bool lower_bitfield_extract_to_shifts; /** Lowers bitfield_insert to bfi/bfm */ bool lower_bitfield_insert; /** Lowers bitfield_insert to bfm, compares, and shifts. */ diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 2824dcebb81b..cb0ea5549169 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -516,6 +516,22 @@ optimizations = [ ('ubfe', 'value', 'offset', 'bits')), 'options->lower_bitfield_extract'), + (('ibitfield_extract', 'value', 'offset', 'bits'), + ('bcsel', ('ieq', 0, 'bits'), + 0, + ('ishr', + ('ishl', 'value', ('isub', ('isub', 32, 'bits'), 'offset')), + ('isub', 32, 'bits'))), + 'options->lower_bitfield_extract_to_shifts'), + + (('ubitfield_extract', 'value', 'offset', 'bits'), + ('iand', + ('ushr', 'value', 'offset'), + ('bcsel', ('ieq', 'bits', 32), + 0xffffffff, + ('bfm', 'bits', 0))), + 'options->lower_bitfield_extract_to_shifts'), + (('extract_i8', a, 'b@32'), ('ishr', ('ishl', a, ('imul', ('isub', 3, b), 8)), 24), 'options->lower_extract_byte'), -- 2.17.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev