Mesa (master): nir/algebraic: eliminate exact a*0.0 if float execution mode allow it
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jan 26 11:59:24 UTC 2021
Module: Mesa
Branch: master
Commit: b729cd58d76f97f3fc04a67569535ee5ef2f5278
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b729cd58d76f97f3fc04a67569535ee5ef2f5278
Author: Rhys Perry <pendingchaos02 at gmail.com>
Date: Wed Jul 15 11:19:56 2020 +0100
nir/algebraic: eliminate exact a*0.0 if float execution mode allow it
fossil-db (GFX10):
Totals from 611 (0.44% of 139391) affected shaders:
SGPRs: 40528 -> 40288 (-0.59%)
VGPRs: 16136 -> 16152 (+0.10%); split: -0.15%, +0.25%
CodeSize: 970192 -> 951036 (-1.97%)
MaxWaves: 10561 -> 10557 (-0.04%); split: +0.08%, -0.11%
Instrs: 174874 -> 172879 (-1.14%); split: -1.18%, +0.04%
fossil-db (GFX10.3):
Totals from 611 (0.44% of 139391) affected shaders:
SGPRs: 40680 -> 40488 (-0.47%)
VGPRs: 18368 -> 18276 (-0.50%); split: -0.57%, +0.07%
CodeSize: 1050712 -> 1033624 (-1.63%); split: -1.64%, +0.02%
MaxWaves: 8658 -> 8674 (+0.18%)
Instrs: 205364 -> 201220 (-2.02%)
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5523>
---
src/compiler/nir/nir_opt_algebraic.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py
index 73c0b3767cf..ed7826da63b 100644
--- a/src/compiler/nir/nir_opt_algebraic.py
+++ b/src/compiler/nir/nir_opt_algebraic.py
@@ -147,6 +147,9 @@ optimizations = [
(('~fadd', a, ('fadd', ('fneg', a), b)), b),
(('fadd', ('fsat', a), ('fsat', ('fneg', a))), ('fsat', ('fabs', a))),
(('~fmul', a, 0.0), 0.0),
+ # The only effect a*0.0 should have is when 'a' is infinity, -0.0 or NaN
+ (('fmul', 'a at 16', 0.0), 0.0, '!'+signed_zero_inf_nan_preserve_16),
+ (('fmul', 'a at 32', 0.0), 0.0, '!'+signed_zero_inf_nan_preserve_32),
(('imul', a, 0), 0),
(('umul_unorm_4x8', a, 0), 0),
(('umul_unorm_4x8', a, ~0), a),
@@ -165,6 +168,8 @@ optimizations = [
(('fmul', ('fsign', a), ('fmul', a, a)), ('fmul', ('fabs', a), a)),
(('fmul', ('fmul', ('fsign', a), a), a), ('fmul', ('fabs', a), a)),
(('~ffma', 0.0, a, b), b),
+ (('ffma at 16(is_only_used_as_float)', 0.0, a, b), b, '!'+signed_zero_inf_nan_preserve_16),
+ (('ffma at 32(is_only_used_as_float)', 0.0, a, b), b, '!'+signed_zero_inf_nan_preserve_32),
(('~ffma', a, b, 0.0), ('fmul', a, b)),
(('ffma at 16', a, b, 0.0), ('fmul', a, b), '!'+signed_zero_inf_nan_preserve_16),
(('ffma at 32', a, b, 0.0), ('fmul', a, b), '!'+signed_zero_inf_nan_preserve_32),
More information about the mesa-commit
mailing list