From: Eric Anholt Date: Fri, 4 May 2018 20:33:47 +0000 (-0700) Subject: nir: Add lowering for ifind_msb to ufind_msb. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d4c7c3c225b7c34669498c15c2d3186cf6a4647e;p=mesa.git nir: Add lowering for ifind_msb to ufind_msb. ufind_msb is easily expressed in terms of clz, and we can reduce ifind_msb to that. Reviewed-by: Matt Turner Reviewed-by: Ian Romanick --- diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 519c0198879..9fca61f0070 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1913,6 +1913,8 @@ typedef struct nir_shader_compiler_options { bool lower_bitfield_insert_to_shifts; /** Lowers bfm to shifts and subtracts. */ bool lower_bfm; + /** Lowers ifind_msb to compare and ufind_msb */ + bool lower_ifind_msb; bool lower_uadd_carry; bool lower_usub_borrow; /** lowers fneg and ineg to fsub and isub. */ diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index eaa8b141640..f6685977f3a 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -555,6 +555,10 @@ optimizations = [ ('bfm', 'bits', 0))), 'options->lower_bitfield_extract_to_shifts'), + (('ifind_msb', 'value'), + ('ufind_msb', ('bcsel', ('ilt', 'value', 0), ('inot', 'value'), 'value')), + 'options->lower_ifind_msb'), + (('extract_i8', a, 'b@32'), ('ishr', ('ishl', a, ('imul', ('isub', 3, b), 8)), 24), 'options->lower_extract_byte'),