From 3e7186d4722d009200781c9fb3b6141b064aeabb Mon Sep 17 00:00:00 2001 From: Jonathan Marek Date: Mon, 12 Nov 2018 12:49:32 -0500 Subject: [PATCH] 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 --- 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 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'), -- 2.30.2