From: Eric Anholt Date: Fri, 4 May 2018 21:02:55 +0000 (-0700) Subject: nir: Add lowering for find_lsb. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6a0db5f08ffac7d43a5b937982262f357a21f95b;p=mesa.git nir: Add lowering for find_lsb. There is a fairly simple relation to turn this into ufind_msb. Reviewed-by: Matt Turner Reviewed-by: Ian Romanick --- diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 9fca61f0070..b9426f8eb4e 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -1915,6 +1915,8 @@ typedef struct nir_shader_compiler_options { bool lower_bfm; /** Lowers ifind_msb to compare and ufind_msb */ bool lower_ifind_msb; + /** Lowers find_lsb to ufind_msb and logic ops */ + bool lower_find_lsb; 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 f6685977f3a..db907df8545 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -559,6 +559,10 @@ optimizations = [ ('ufind_msb', ('bcsel', ('ilt', 'value', 0), ('inot', 'value'), 'value')), 'options->lower_ifind_msb'), + (('find_lsb', 'value'), + ('ufind_msb', ('iand', 'value', ('ineg', 'value'))), + 'options->lower_find_lsb'), + (('extract_i8', a, 'b@32'), ('ishr', ('ishl', a, ('imul', ('isub', 3, b), 8)), 24), 'options->lower_extract_byte'),