From: Jonathan Marek Date: Mon, 12 Nov 2018 17:49:32 +0000 (-0500) Subject: nir: add fceil lowering X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3e7186d4722d009200781c9fb3b6141b064aeabb;p=mesa.git nir: add fceil lowering lowers ceil(x) as -floor(-x) Signed-off-by: Jonathan Marek Reviewed-by: Jason Ekstrand Reviewed-by: Christian Gmeiner Signed-off-by: Rob Clark --- diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index a292ec73e1e..db935c8496b 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2130,6 +2130,9 @@ typedef struct nir_shader_compiler_options { /** lowers ffract to fsub+ffloor: */ bool lower_ffract; + /** lowers fceil to fneg+ffloor+fneg: */ + bool lower_fceil; + bool lower_ldexp; bool lower_pack_half_2x16; diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 0d8802582aa..f2a7be0c403 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -125,6 +125,7 @@ optimizations = [ (('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'), + (('fceil', a), ('fneg', ('ffloor', ('fneg', a))), 'options->lower_fceil'), (('~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'), (('~fadd@64', ('fmul', a, ('fadd', 1.0, ('fneg', c ))), ('fmul', b, c )), ('flrp', a, b, c), '!options->lower_flrp64'),