diff options
Diffstat (limited to 'src/compiler/nir/nir_opt_algebraic.py')
-rw-r--r-- | src/compiler/nir/nir_opt_algebraic.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index f8db2b690ac..011263a14d7 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -45,10 +45,11 @@ d = 'd' # however, be used for backend-requested lowering operations as those need to # happen regardless of precision. # -# Variable names are specified as "[#]name[@type]" where "#" inicates that -# the given variable will only match constants and the type indicates that +# Variable names are specified as "[#]name[@type][(cond)]" where "#" inicates +# that the given variable will only match constants and the type indicates that # the given variable will only match values from ALU instructions with the -# given output type. +# given output type, and (cond) specifies an additional condition function +# (see nir_search_helpers.h). # # For constants, you have to be careful to make sure that it is the right # type because python is unaware of the source and destination types of the @@ -62,6 +63,14 @@ d = 'd' # constructed value should have that bit-size. optimizations = [ + + (('imul', a, '#b@32(is_pos_power_of_two)'), ('ishl', a, ('find_lsb', b))), + (('imul', a, '#b@32(is_neg_power_of_two)'), ('ineg', ('ishl', a, ('find_lsb', ('iabs', b))))), + (('udiv', a, '#b@32(is_pos_power_of_two)'), ('ushr', a, ('find_lsb', b))), + (('idiv', a, '#b@32(is_pos_power_of_two)'), ('imul', ('isign', a), ('ushr', ('iabs', a), ('find_lsb', b))), 'options->lower_idiv'), + (('idiv', a, '#b@32(is_neg_power_of_two)'), ('ineg', ('imul', ('isign', a), ('ushr', ('iabs', a), ('find_lsb', ('iabs', b))))), 'options->lower_idiv'), + (('umod', a, '#b(is_pos_power_of_two)'), ('iand', a, ('isub', b, 1))), + (('fneg', ('fneg', a)), a), (('ineg', ('ineg', a)), a), (('fabs', ('fabs', a)), ('fabs', a)), |