From 42d2cae90750360922ce1ca5af5609a1b661e669 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 6 Feb 2019 13:12:25 -0800 Subject: nir: Move panfrost's isign lowering to nir_opt_algebraic. I wanted to reuse this from v3d. Reviewed-by: Alyssa Rosenzweig Reviewed-by: Ian Romanick --- src/compiler/nir/nir.h | 3 +++ src/compiler/nir/nir_opt_algebraic.py | 2 ++ src/gallium/drivers/panfrost/midgard/midgard_compile.h | 1 + src/gallium/drivers/panfrost/midgard/midgard_nir_algebraic.py | 1 - 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 353a1604785..94ca6c46468 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2156,6 +2156,9 @@ typedef struct nir_shader_compiler_options { /** enables rules to lower idiv by power-of-two: */ bool lower_idiv; + /** enables rules to lower isign to imin+imax */ + bool lower_isign; + /* Does the native fdot instruction replicate its result for four * components? If so, then opt_algebraic_late will turn all fdotN * instructions into fdot_replicatedN instructions. diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 75a3d2ad238..11d6aca1183 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -758,6 +758,8 @@ optimizations = [ ('extract_i8', 'v', 3))), 127.0))), 'options->lower_unpack_snorm_4x8'), + + (('isign', a), ('imin', ('imax', a, -1), 1), 'options->lower_isign'), ] invert = OrderedDict([('feq', 'fne'), ('fne', 'feq'), ('fge', 'flt'), ('flt', 'fge')]) diff --git a/src/gallium/drivers/panfrost/midgard/midgard_compile.h b/src/gallium/drivers/panfrost/midgard/midgard_compile.h index 887fd4e746f..2fcbc317164 100644 --- a/src/gallium/drivers/panfrost/midgard/midgard_compile.h +++ b/src/gallium/drivers/panfrost/midgard/midgard_compile.h @@ -71,6 +71,7 @@ static const nir_shader_compiler_options midgard_nir_options = { .lower_fmod64 = true, .lower_fdiv = true, .lower_idiv = true, + .lower_isign = true, .vertex_id_zero_based = true, .lower_extract_byte = true, diff --git a/src/gallium/drivers/panfrost/midgard/midgard_nir_algebraic.py b/src/gallium/drivers/panfrost/midgard/midgard_nir_algebraic.py index 44441727b78..07ea427359b 100644 --- a/src/gallium/drivers/panfrost/midgard/midgard_nir_algebraic.py +++ b/src/gallium/drivers/panfrost/midgard/midgard_nir_algebraic.py @@ -31,7 +31,6 @@ b = 'b' algebraic = [ (('b2i32', a), ('iand@32', "a@32", 1)), - (('isign', a), ('imin', ('imax', a, -1), 1)), (('fge', a, b), ('flt', b, a)), # XXX: We have hw ops for this, just unknown atm.. -- cgit v1.2.3