From 6d52e6fd2c53355ee67d4da7518b2c59d90598eb Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Wed, 22 Feb 2023 12:59:16 -0800 Subject: [PATCH] nir: Port a floor->truncate algebraic opt pattern from GLSL. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Prevents regression when dropping code from the GLSL optimizer. Acked-by: Timothy Arceri Reviewed-by: Marek Olšák Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 072b992..9d2fbb5 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -129,6 +129,8 @@ optimizations = [ '!options->lower_bitops'), (('irem', a, '#b(is_neg_power_of_two)'), ('irem', a, ('iabs', b)), '!options->lower_bitops'), + (('~fmul', ('fsign', a), ('ffloor', ('fadd', ('fabs', a), 0.5))), ('ftrunc', ('fadd', a, ('fmul', ('fsign', a), 0.5))), '!options->lower_ftrunc || options->lower_ffloor'), + (('~fneg', ('fneg', a)), a), (('ineg', ('ineg', a)), a), (('fabs', ('fneg', a)), ('fabs', a)), -- 2.7.4