agx: Handle constant-offset in address matching

Match iadd(x, #y). The format shift will get constant-folded away and, if y
is sufficiently small, the constant will be inlined by the AGX backend
optimizer. This gets rid of piles of 64-bit arithmetic from lowering UBOs. It
probably doesn't matter for perf since that's happening in preamble shaders but
it *is* noisy.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21108>
This commit is contained in:
Alyssa Rosenzweig 2023-02-03 16:15:40 -05:00 committed by Marge Bot
parent c3f7abaaef
commit 221311e1e9

View file

@ -37,6 +37,17 @@ match_address(nir_ssa_scalar base, int8_t format_shift)
};
for (unsigned i = 0; i < ARRAY_SIZE(summands); ++i) {
/* We can add a small constant to the 64-bit base for free */
if (nir_ssa_scalar_is_const(summands[i])) {
return (struct match){
.base = summands[1 - i],
.offset = summands[i],
.shift = -format_shift,
.sign_extend = true,
};
}
/* Otherwise, we can only add an offset extended from 32-bits */
if (!nir_ssa_scalar_is_alu(summands[i]))
continue;