diff options
author | Jose Maria Casanova Crespo <jmcasanova@igalia.com> | 2020-10-09 18:33:26 +0200 |
---|---|---|
committer | Jose Maria Casanova Crespo <jmcasanova@igalia.com> | 2020-10-10 13:16:37 +0200 |
commit | e7127b3468cbaa888bfd21ebeb2f34ab8dd8b78d (patch) | |
tree | e2eb3b008c3bc71335b5fd1af0f411e3c2cf7ce0 | |
parent | 210db65b1a10429fa109ff7a54a8a230d05575fa (diff) |
nir/algebraic: optimize iand/ior of (n)eq zero when umax/umin not available
Before 8e1b75b330954a ("nir/algebraic: optimize iand/ior of (n)eq zero") this
optimization didn't need the use of umax/umin. VC4 HW supports only signed
integer max/min operations.
lower_umin and lower_umax are added to allow enabling previous optimizations
behaviour for this cases.
Fixes: 8e1b75b330954a ("nir/algebraic: optimize iand/ior of (n)eq zero")
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7083>
-rw-r--r-- | src/compiler/nir/nir.h | 6 | ||||
-rw-r--r-- | src/compiler/nir/nir_opt_algebraic.py | 10 |
2 files changed, 12 insertions, 4 deletions
diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index cca046f76db..2765ad0dae3 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -3160,6 +3160,12 @@ typedef struct nir_shader_compiler_options { /** enables rules to lower iabs to ineg+imax */ bool lower_iabs; + /** enable rules that avoid generating umax from signed integer ops */ + bool lower_umax; + + /** enable rules that avoid generating umin from signed integer ops */ + bool lower_umin; + /* lower fdph to fdot4 */ bool lower_fdph; diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 2bb9b41fb15..acd5a2bab68 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -738,10 +738,12 @@ optimizations.extend([ # Integer sizes for s in [8, 16, 32, 64]: optimizations.extend([ - (('iand', ('ieq', 'a@{}'.format(s), 0), ('ieq', 'b@{}'.format(s), 0)), ('ieq', ('umax', a, b), 0)), - (('ior', ('ieq', 'a@{}'.format(s), 0), ('ieq', 'b@{}'.format(s), 0)), ('ieq', ('umin', a, b), 0)), - (('iand', ('ine', 'a@{}'.format(s), 0), ('ine', 'b@{}'.format(s), 0)), ('ine', ('umin', a, b), 0)), - (('ior', ('ine', 'a@{}'.format(s), 0), ('ine', 'b@{}'.format(s), 0)), ('ine', ('umax', a, b), 0)), + (('iand', ('ieq', 'a@{}'.format(s), 0), ('ieq', 'b@{}'.format(s), 0)), ('ieq', ('ior', a, b), 0), 'options->lower_umax'), + (('ior', ('ine', 'a@{}'.format(s), 0), ('ine', 'b@{}'.format(s), 0)), ('ine', ('ior', a, b), 0), 'options->lower_umin'), + (('iand', ('ieq', 'a@{}'.format(s), 0), ('ieq', 'b@{}'.format(s), 0)), ('ieq', ('umax', a, b), 0), '!options->lower_umax'), + (('ior', ('ieq', 'a@{}'.format(s), 0), ('ieq', 'b@{}'.format(s), 0)), ('ieq', ('umin', a, b), 0), '!options->lower_umin'), + (('iand', ('ine', 'a@{}'.format(s), 0), ('ine', 'b@{}'.format(s), 0)), ('ine', ('umin', a, b), 0), '!options->lower_umin'), + (('ior', ('ine', 'a@{}'.format(s), 0), ('ine', 'b@{}'.format(s), 0)), ('ine', ('umax', a, b), 0), '!options->lower_umax'), # True/False are ~0 and 0 in NIR. b2i of True is 1, and -1 is ~0 (True). (('ineg', ('b2i{}'.format(s), 'a@{}'.format(s))), a), |