Mesa (master): nir/algebraic: Mark comparisons generated from lowered fsign precise
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jan 5 02:24:37 UTC 2021
Module: Mesa
Branch: master
Commit: ec16f935fe391fa452952b3765ad00b403aac491
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ec16f935fe391fa452952b3765ad00b403aac491
Author: Ian Romanick <ian.d.romanick at intel.com>
Date: Wed Feb 19 12:47:21 2020 -0800
nir/algebraic: Mark comparisons generated from lowered fsign precise
This prevents other transformations from converting them to 'a != 0'.
For example, both of these transformations can do this:
(('~flt', 0.0, ('fabs', a)), ('fne', a, 0.0)),
(('~flt', ('fneg', ('fabs', a)), 0.0), ('fne', a, 0.0)),
Both fsign(fabs(NaN)) and fsign(fneg(fabs(NaN))) should produce zero,
but, since 'NaN != 0.0' is true, cascading these transformations could
cause them to generate 1.0 or -1.0 respecively.
No shader-db or fossil-db changes on any Intel platform.
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6358>
---
src/compiler/nir/nir_opt_algebraic.py | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 1a725a74f65..142bf99f201 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -572,8 +572,9 @@ optimizations.extend([
# SignedZeroInfNanPreserve is set, but we don't currently have any way of
# representing this in the optimizations other than the usual ~.
(('~fmax', ('fmin', a, 0.0), -1.0), ('fneg', ('fsat', ('fneg', a))), '!options->lower_fsat'),
- # fsat(fsign(NaN)) = fsat(0) = 0, and b2f(0 < NaN) = b2f(False) = 0.
- (('fsat', ('fsign', a)), ('b2f', ('flt', 0.0, a))),
+ # fsat(fsign(NaN)) = fsat(0) = 0, and b2f(0 < NaN) = b2f(False) = 0. Mark
+ # the new comparison precise to prevent it being changed to 'a != 0'.
+ (('fsat', ('fsign', a)), ('b2f', ('!flt', 0.0, a))),
(('fsat', ('b2f', a)), ('b2f', a)),
(('fsat', a), ('fmin', ('fmax', a, 0.0), 1.0), 'options->lower_fsat'),
(('fsat', ('fsat', a)), ('fsat', a)),
@@ -1576,7 +1577,9 @@ optimizations.extend([
(('imin', ('imax', a, -1), 1), ('isign', a), '!options->lower_isign'),
(('imax', ('imin', a, 1), -1), ('isign', a), '!options->lower_isign'),
# float(0 < NaN) - float(NaN < 0) = float(False) - float(False) = 0 - 0 = 0
- (('fsign', a), ('fsub', ('b2f', ('flt', 0.0, a)), ('b2f', ('flt', a, 0.0))), 'options->lower_fsign'),
+ # Mark the new comparisons precise to prevent them being changed to 'a !=
+ # 0' or 'a == 0'.
+ (('fsign', a), ('fsub', ('b2f', ('!flt', 0.0, a)), ('b2f', ('!flt', a, 0.0))), 'options->lower_fsign'),
# Address/offset calculations:
# Drivers supporting imul24 should use the nir_lower_amul() pass, this
More information about the mesa-commit
mailing list