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>
This commit is contained in:
Connor Abbott 2023-10-27 14:37:53 +02:00 committed by Marge Bot
parent 17cb1c78bd
commit 32308fe9f1
2 changed files with 3 additions and 3 deletions

View file

@ -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.

View file

@ -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')),
]