asahi: Fix agx_pack unrolling

The loop is supposed to execute exactly once, but the previous logic
inadvertently executes 0 or 1 times depending on whether dst is NULL (it never
is). Reexpress the loop to execute exactly once, eliminating the unnecessary
branch in this hot path. Noticed when reading the NIR of generated pack code.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25498>
This commit is contained in:
Alyssa Rosenzweig
2023-09-19 16:15:20 -04:00
committed by Marge Bot
parent 7193849f30
commit 59499d8dbc
+3 -3
View File
@@ -99,10 +99,10 @@ __gen_from_groups(uint32_t value, uint32_t group_size, uint32_t length)
#define agx_pack(dst, T, name) \\
for (struct AGX_ ## T name = { AGX_ ## T ## _header }, \\
*_loop_terminate = (void *) (dst); \\
__builtin_expect(_loop_terminate != NULL, 1); \\
*_loop_count = (void *) ((uintptr_t) 0); \\
(uintptr_t)_loop_count < 1; \\
({ AGX_ ## T ## _pack((uint32_t *) (dst), &name); \\
_loop_terminate = NULL; }))
_loop_count = (void*)(((uintptr_t)_loop_count) + 1); }))
#define agx_unpack(fp, src, T, name) \\
struct AGX_ ## T name; \\