From ef02581590c951f090d95d53ebefc5f365f3c890 Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Wed, 22 Feb 2023 12:22:03 -0800 Subject: [PATCH] nir: Add optimization for fdot(x, 0) -> 0. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We had all these nice fdot opts to drop individual channels that were 0, but nothing handling it being entirely 0! Avoids r300g regression when dropping them from GLSL. Acked-by: Timothy Arceri Reviewed-by: Marek Olšák Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index cd83ded3a08..072b9929480 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -401,6 +401,10 @@ optimizations.extend([ (('fdph', a, b), ('fdot4', ('vec4', 'a.x', 'a.y', 'a.z', 1.0), b), 'options->lower_fdph'), + (('fdot4', a, 0.0), 0.0), + (('fdot3', a, 0.0), 0.0), + (('fdot2', a, 0.0), 0.0), + (('fdot4', ('vec4', a, b, c, 1.0), d), ('fdph', ('vec3', a, b, c), d), '!options->lower_fdph'), (('fdot4', ('vec4', a, 0.0, 0.0, 0.0), b), ('fmul', a, b)), (('fdot4', ('vec4', a, b, 0.0, 0.0), c), ('fdot2', ('vec2', a, b), c)),