mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-08 06:20:19 +01:00
nir: Model AGX-specific multiply-shift-add
Models `(a * b) + (c << d)` in general, as implemented in various forms on AGX. This will be fused with backend NIR opt algebraic rules, both for the literal pattern as well as to strength reduce certain multiplications, e.g. replacing a * 5 with `a + (a << 2)` expressed as imadshl_agx(a, 1, a, 2). Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Asahi Lina <lina@asahilina.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22695>
This commit is contained in:
parent
3df4ae3334
commit
18e19882fa
1 changed files with 8 additions and 0 deletions
|
|
@ -1298,6 +1298,14 @@ opcode("extr_agx", 0, tuint32,
|
|||
}
|
||||
""");
|
||||
|
||||
# AGX multiply-shift-add. Corresponds to iadd/isub/imad/imsub instructions.
|
||||
# The shift must be <= 4 (domain restriction). For performance, it should be
|
||||
# constant.
|
||||
opcode("imadshl_agx", 0, tint, [0, 0, 0, 0], [tint, tint, tint, tint], False,
|
||||
"", f"(src0 * src1) + (src2 << src3)")
|
||||
opcode("imsubshl_agx", 0, tint, [0, 0, 0, 0], [tint, tint, tint, tint], False,
|
||||
"", f"(src0 * src1) - (src2 << src3)")
|
||||
|
||||
# 24b multiply into 32b result (with sign extension)
|
||||
binop("imul24", tint32, _2src_commutative + associative,
|
||||
"(((int32_t)src0 << 8) >> 8) * (((int32_t)src1 << 8) >> 8)")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue