From 1b0edf3f3302dc341202c42005d1c7e12a5ea800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 15 May 2024 10:32:09 +0200 Subject: [PATCH] aco/ra: Fix array access when finding register for subdword variables Part-of: --- src/amd/compiler/aco_register_allocation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index a6631b02dbb..4264c1e6281 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -992,10 +992,11 @@ get_reg_simple(ra_ctx& ctx, const RegisterFile& reg_file, DefInfo info) if (!bounds.contains({PhysReg{entry.first}, rc.size()})) continue; + auto it = entry.second.begin(); for (unsigned i = 0; i < 4; i += info.stride) { /* check if there's a block of free bytes large enough to hold the register */ bool reg_found = - std::all_of(&entry.second[i], &entry.second[std::min(4u, i + rc.bytes())], + std::all_of(std::next(it, i), std::next(it, std::min(4u, i + rc.bytes())), [](unsigned v) { return v == 0; }); /* check if also the neighboring reg is free if needed */