From b6bed115a5efb281b450c749418646b4ea2e7db7 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Fri, 12 Apr 2019 10:12:27 +0200 Subject: [PATCH] nir: add lower_ftrunc Port TGSI TRUNC lowering to nir Signed-off-by: Christian Gmeiner Reviewed-by: Jason Ekstrand --- src/compiler/nir/nir.h | 2 ++ src/compiler/nir/nir_opt_algebraic.py | 1 + 2 files changed, 3 insertions(+) diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 91cad825653..ad72a5c9222 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -2246,6 +2246,8 @@ typedef struct nir_shader_compiler_options { /** lowers fceil to fneg+ffloor+fneg: */ bool lower_fceil; + bool lower_ftrunc; + 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 b8d418c2e49..e8696abaf52 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -131,6 +131,7 @@ optimizations = [ (('flrp@16', a, b, c), ('fadd', ('fmul', c, ('fsub', b, a)), a), 'options->lower_flrp16'), (('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'), + (('ftrunc', a), ('bcsel', ('flt', a, 0.0), ('fneg', ('ffloor', ('fabs', a))), ('ffloor', ('fabs', a))), 'options->lower_ftrunc'), (('ffloor', a), ('fsub', a, ('ffract', a)), 'options->lower_ffloor'), (('fadd', a, ('fneg', ('ffract', a))), ('ffloor', a), '!options->lower_ffloor'), (('ffract', a), ('fsub', a, ('ffloor', a)), 'options->lower_ffract'), -- 2.30.2