nir: Port a floor->truncate algebraic opt pattern from GLSL.

Prevents regression when dropping code from the GLSL optimizer.

Acked-by: Timothy Arceri <tarceri@itsqueeze.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21475>
This commit is contained in:
Emma Anholt
2023-02-22 12:59:16 -08:00
committed by Marge Bot
parent 6229d34b91
commit 6d52e6fd2c

View File

@@ -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)),