diff options
author | Connor Abbott <cwabbott0@gmail.com> | 2023-10-27 14:37:53 +0200 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-04-26 12:55:14 +0000 |
commit | 32308fe9f1c6c9ef6716be4d9812ad41794f48b4 (patch) | |
tree | faac0e28e2ce7451cc1d73721d17d64cc754fe93 | |
parent | 17cb1c78bde01eedbfe0f5e874b1208d8d08d570 (diff) |
ir3/nir: Fix imadsh_mix16 definition
The constant-folding definition and comments say that it takes the high
16 bits of the first source and low 16 bits of the second source, but
actually it's the opposite. The algebraic optimization, which actually
happens and needs to be correct, was correct but the comment above it
was wrong.
Note that in the way we use it when lowering multiplications, the
ordering doesn't matter.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22075>
-rw-r--r-- | src/compiler/nir/nir_opcodes.py | 4 | ||||
-rw-r--r-- | src/compiler/nir/nir_opt_algebraic.py | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index 7bd7a776b11..b04c2f363ef 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -1248,11 +1248,11 @@ dst.p = src15.x; binop("amul", tint, _2src_commutative + associative, "src0 * src1") # ir3-specific instruction that maps directly to mul-add shift high mix, -# (IMADSH_MIX16 i.e. ah * bl << 16 + c). It is used for lowering integer +# (IMADSH_MIX16 i.e. al * bh << 16 + c). It is used for lowering integer # multiplication (imul) on Freedreno backend.. opcode("imadsh_mix16", 0, tint32, [0, 0, 0], [tint32, tint32, tint32], False, "", """ -dst = ((((src0 & 0xffff0000) >> 16) * (src1 & 0x0000ffff)) << 16) + src2; +dst = ((((src0 & 0x0000ffff) << 16) * (src1 & 0xffff0000)) >> 16) + src2; """) # ir3-specific instruction that maps directly to ir3 mad.s24. diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 20e3836ff58..6446c4915b7 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -2751,7 +2751,7 @@ for op in ['fddx', 'fddx_fine', 'fddx_coarse', optimizations += [ # 'al * bl': If either 'al' or 'bl' is zero, return zero. (('umul_low', '#a(is_lower_half_zero)', 'b'), (0)), - # '(ah * bl) << 16 + c': If either 'ah' or 'bl' is zero, return 'c'. + # '(al * bh) << 16 + c': If either 'al' or 'bh' is zero, return 'c'. (('imadsh_mix16', '#a@32(is_lower_half_zero)', 'b@32', 'c@32'), ('c')), (('imadsh_mix16', 'a@32', '#b@32(is_upper_half_zero)', 'c@32'), ('c')), ] |