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;