From f8c7661ecaa782fdde105a4bf756023eb88ea780 Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 25 Aug 2020 19:10:52 +0100 Subject: [PATCH] aco: try to better align 8+ dword SGPR vectors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This doesn't have much of an effect, but it helps avoid a pathological case for Assassin's Creed Valhalla and a RDR2 shader with a future change. fossil-db (Sienna): Totals from 55074 (39.51% of 139391) affected shaders: SGPRs: 3515076 -> 3567744 (+1.50%); split: -0.01%, +1.51% CodeSize: 206942120 -> 206941868 (-0.00%); split: -0.00%, +0.00% Instrs: 39625900 -> 39625837 (-0.00%); split: -0.00%, +0.00% Cycles: 1640088780 -> 1640088828 (+0.00%); split: -0.00%, +0.00% Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/4070 Part-of: --- src/amd/compiler/aco_register_allocation.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 3f0f44b6bf6..2fadcef4a72 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -632,16 +632,18 @@ std::pair get_reg_simple(ra_ctx& ctx, uint32_t stride = info.rc.is_subdword() ? DIV_ROUND_UP(info.stride, 4) : info.stride; RegClass rc = info.rc; + DefInfo new_info = info; + for (unsigned new_stride = 16; new_stride > stride; new_stride /= 2) { + if (size % new_stride) + continue; + new_info.stride = new_stride; + std::pair res = get_reg_simple(ctx, reg_file, new_info); + if (res.second) + return res; + } + if (stride == 1) { info.rc = RegClass(rc.type(), size); - for (unsigned new_stride = 8; new_stride > 1; new_stride /= 2) { - if (size % new_stride) - continue; - info.stride = new_stride; - std::pair res = get_reg_simple(ctx, reg_file, info); - if (res.second) - return res; - } /* best fit algorithm: find the smallest gap to fit in the variable */ unsigned best_pos = 0xFFFF;