From 3f782cdd2591259e120b76aa4891c305cc1e8cb6 Mon Sep 17 00:00:00 2001 From: Andres Gomez Date: Tue, 23 Apr 2019 15:54:24 +0200 Subject: [PATCH] nir/algebraic: mark float optimizations returning one parameter as inexact MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit With the arrival of VK_KHR_shader_float_controls algebraic optimizations for float types of the form (('fop', a, b), a) become inexact depending on the execution mode. For example, if we have activated SHADER_DENORM_FLUSH_TO_ZERO, in case of a denorm value for the "a" parameter, we cannot return it still as a denorm, it needs to be flushed to zero. Therefore, we mark now all those operations as inexact. Suggested-by: Samuel Iglesias Gonsálvez Signed-off-by: Andres Gomez Reviewed-by: Connor Abbott --- src/compiler/nir/nir_opt_algebraic.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index a94829d9bfb..e3b503f3825 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -100,7 +100,7 @@ optimizations = [ (('idiv', a, '#b@32(is_neg_power_of_two)'), ('ineg', ('imul', ('isign', a), ('ushr', ('iabs', a), ('find_lsb', ('iabs', b))))), 'options->lower_idiv'), (('umod', a, '#b(is_pos_power_of_two)'), ('iand', a, ('isub', b, 1))), - (('fneg', ('fneg', a)), a), + (('~fneg', ('fneg', a)), a), (('ineg', ('ineg', a)), a), (('fabs', ('fabs', a)), ('fabs', a)), (('fabs', ('fneg', a)), ('fabs', a)), @@ -126,7 +126,7 @@ optimizations = [ (('imul', a, 0), 0), (('umul_unorm_4x8', a, 0), 0), (('umul_unorm_4x8', a, ~0), a), - (('fmul', a, 1.0), a), + (('~fmul', a, 1.0), a), (('imul', a, 1), a), (('fmul', a, -1.0), ('fneg', a)), (('imul', a, -1), ('ineg', a)), @@ -383,7 +383,7 @@ optimizations.extend([ (('feq', ('fmin', ('fneg', ('b2f', 'a@1')), 'b@1'), 0.0), ('iand', ('inot', a), ('fge', b, 0.0))), (('feq', ('b2f', 'a@1'), 0.0), ('inot', a)), - (('fne', ('b2f', 'a@1'), 0.0), a), + (('~fne', ('b2f', 'a@1'), 0.0), a), (('ieq', ('b2i', 'a@1'), 0), ('inot', a)), (('ine', ('b2i', 'a@1'), 0), a), @@ -462,8 +462,8 @@ optimizations.extend([ (('bcsel', a, a, b), ('ior', a, b)), (('bcsel', a, b, False), ('iand', a, b)), (('bcsel', a, b, a), ('iand', a, b)), - (('fmin', a, a), a), - (('fmax', a, a), a), + (('~fmin', a, a), a), + (('~fmax', a, a), a), (('imin', a, a), a), (('imax', a, a), a), (('umin', a, a), a), @@ -480,9 +480,9 @@ optimizations.extend([ (('imin', a, ('ineg', a)), ('ineg', ('iabs', a))), (('fmin', a, ('fneg', ('fabs', a))), ('fneg', ('fabs', a))), (('imin', a, ('ineg', ('iabs', a))), ('ineg', ('iabs', a))), - (('fmin', a, ('fabs', a)), a), + (('~fmin', a, ('fabs', a)), a), (('imin', a, ('iabs', a)), a), - (('fmax', a, ('fneg', ('fabs', a))), a), + (('~fmax', a, ('fneg', ('fabs', a))), a), (('imax', a, ('ineg', ('iabs', a))), a), (('fmax', a, ('fabs', a)), ('fabs', a)), (('imax', a, ('iabs', a)), ('iabs', a)), @@ -768,7 +768,7 @@ optimizations.extend([ (('bcsel', a, ('b2f(is_used_once)', 'b@32'), ('b2f', 'c@32')), ('b2f', ('bcsel', a, b, c))), (('bcsel', a, b, b), b), - (('fcsel', a, b, b), b), + (('~fcsel', a, b, b), b), # D3D Boolean emulation (('bcsel', a, -1, 0), ('ineg', ('b2i', 'a@1'))), -- 2.30.2