From 74c26ebaa4bd515386cb81579625530b7c455e47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Molinari?= Date: Wed, 11 Feb 2026 16:07:54 +0100 Subject: [PATCH] pan/crc: Optimize clear color hashing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Take advantage of XOR associativity to break the loop-carried dependency chain and help compiler auto-vectorization. Signed-off-by: Loïc Molinari --- src/panfrost/lib/pan_desc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/panfrost/lib/pan_desc.c b/src/panfrost/lib/pan_desc.c index 96d0830fc3f..b074c616839 100644 --- a/src/panfrost/lib/pan_desc.c +++ b/src/panfrost/lib/pan_desc.c @@ -1103,6 +1103,7 @@ pan_crc_maybe_enable_flushed(struct pan_crc *crc, struct pan_crc_state *state, static uint64_t pan_crc_clear_color(const struct pan_fb_info *fb) { + uint64_t base[4] = { 0, }; /* Compiler auto-vectorization hint */ uint64_t crc_clear_flag = 1; uint64_t crc_clear_base = 0; uint64_t crc_init = 0; @@ -1139,7 +1140,9 @@ pan_crc_clear_color(const struct pan_fb_info *fb) for (unsigned i = 0; i < fb->rt_count; ++i) if (fb->rts[i].clear) for (unsigned j = 0; j < 4; ++j) - crc_clear_base ^= 32749 * fb->rts[i].clear_value[j]; + base[i] ^= 32749 * fb->rts[i].clear_value[j]; + + crc_clear_base = (base[0] ^ base[1]) ^ (base[2] ^ base[3]); return (crc_clear_flag << 63) | (crc_clear_base << 16) | crc_init; }