nir/opt_algebraic: lower 16-bit imul_high & umul_high

Tested-by: Dieter Nützel <Dieter@nuetzel-hh.de>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34016>
This commit is contained in:
Marek Olšák 2025-03-11 22:40:30 -04:00 committed by Marge Bot
parent b14c8128bf
commit 1d5c42528b
3 changed files with 5 additions and 0 deletions

View file

@ -57,6 +57,7 @@ void ac_nir_set_options(struct radeon_info *info, bool use_llvm,
options->lower_unpack_unorm_4x8 = true;
options->lower_unpack_half_2x16 = true;
options->lower_fpow = true;
options->lower_mul_high16 = true;
options->lower_mul_2x32_64 = true;
options->lower_iadd_sat = info->gfx_level <= GFX8;
options->lower_hadd = true;

View file

@ -2671,6 +2671,9 @@ optimizations.extend([
(('imul24', a, '#b@32(is_pos_power_of_two)'), ('ishl', a, ('find_lsb', b)), '!options->lower_bitops'),
(('imul24', a, '#b@32(is_neg_power_of_two)'), ('ineg', ('ishl', a, ('find_lsb', ('iabs', b)))), '!options->lower_bitops'),
(('imul24', a, 0), (0)),
(('imul_high@16', a, b), ('i2i16', ('ishr', ('imul24_relaxed', ('i2i32', a), ('i2i32', b)), 16)), 'options->lower_mul_high16'),
(('umul_high@16', a, b), ('u2u16', ('ushr', ('umul24_relaxed', ('u2u32', a), ('u2u32', b)), 16)), 'options->lower_mul_high16'),
])
for bit_size in [8, 16, 32, 64]:

View file

@ -243,6 +243,7 @@ typedef struct nir_shader_compiler_options {
bool lower_usub_borrow;
/** Lowers imul_high/umul_high to 16-bit multiplies and carry operations. */
bool lower_mul_high;
bool lower_mul_high16;
/** lowers fneg to fmul(x, -1.0). Driver must call nir_opt_algebraic_late() */
bool lower_fneg;
/** lowers ineg to isub. Driver must call nir_opt_algebraic_late(). */