From 2b1fc1a7fe09b940ccd08c78c8dc4bcb789e8861 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Tue, 4 Mar 2025 15:29:28 +0100 Subject: [PATCH] nir: add option to keep mul24_relaxed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 8 ++++---- src/compiler/nir/nir_shader_compiler_options.h | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 49bfabb6767..a6b659aea73 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -2649,12 +2649,12 @@ optimizations.extend([ '!options->has_umad24'), # Relaxed 24bit ops - (('imul24_relaxed', a, b), ('imul24', a, b), 'options->has_imul24'), - (('imul24_relaxed', a, b), ('imul', a, b), '!options->has_imul24'), + (('imul24_relaxed', a, b), ('imul24', a, b), '!options->has_mul24_relaxed && options->has_imul24'), + (('imul24_relaxed', a, b), ('imul', a, b), '!options->has_mul24_relaxed && !options->has_imul24'), (('umad24_relaxed', a, b, c), ('umad24', a, b, c), 'options->has_umad24'), (('umad24_relaxed', a, b, c), ('iadd', ('umul24_relaxed', a, b), c), '!options->has_umad24'), - (('umul24_relaxed', a, b), ('umul24', a, b), 'options->has_umul24'), - (('umul24_relaxed', a, b), ('imul', a, b), '!options->has_umul24'), + (('umul24_relaxed', a, b), ('umul24', a, b), '!options->has_mul24_relaxed && options->has_umul24'), + (('umul24_relaxed', a, b), ('imul', a, b), '!options->has_mul24_relaxed && !options->has_umul24'), (('imad24_ir3', a, b, 0), ('imul24', a, b)), (('imad24_ir3', a, 0, c), (c)), diff --git a/src/compiler/nir/nir_shader_compiler_options.h b/src/compiler/nir/nir_shader_compiler_options.h index 4a276ba3d64..aa972f7a753 100644 --- a/src/compiler/nir/nir_shader_compiler_options.h +++ b/src/compiler/nir/nir_shader_compiler_options.h @@ -511,6 +511,11 @@ typedef struct nir_shader_compiler_options { * to imul with masked inputs */ bool has_umul24; + /** Backend supports imul24_relaxed and umul24_relaxed, if not set they will be lowered + * to imul24, umul24 or imul. + */ + bool has_mul24_relaxed; + /** Backend supports 32-bit imad */ bool has_imad32;