From c6aaafa3a1745c0c5a3b4cc0e023b74e2eccbaf4 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Sat, 1 Sep 2018 21:15:27 +0200 Subject: [PATCH] nir: add lowering for ffloor Signed-off-by: Christian Gmeiner Reviewed-by: Jason Ekstrand --- src/compiler/nir/nir.h | 3 +++ src/compiler/nir/nir_opt_algebraic.py | 1 + 2 files changed, 4 insertions(+) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index f984c76fe66..c469e111b2c 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2083,6 +2083,9 @@ typedef struct nir_shader_compiler_options { */ bool fdot_replicates; + /** lowers ffloor to fsub+ffract: */ + bool lower_ffloor; + /** lowers ffract to fsub+ffloor: */ bool lower_ffract; diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 8b24daddfdc..0d8802582aa 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -123,6 +123,7 @@ optimizations = [ (('~flrp', a, 0.0, c), ('fadd', ('fmul', ('fneg', a), c), a)), (('flrp@32', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 'options->lower_flrp32'), (('flrp@64', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 'options->lower_flrp64'), + (('ffloor', a), ('fsub', a, ('ffract', a)), 'options->lower_ffloor'), (('ffract', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'), (('~fadd', ('fmul', a, ('fadd', 1.0, ('fneg', ('b2f', c)))), ('fmul', b, ('b2f', c))), ('bcsel', c, b, a), 'options->lower_flrp32'), (('~fadd@32', ('fmul', a, ('fadd', 1.0, ('fneg', c ))), ('fmul', b, c )), ('flrp', a, b, c), '!options->lower_flrp32'), -- 2.30.2