From 25235a9f2e2574afb5f31540614a0e1671c5036e Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Thu, 8 Aug 2024 15:04:39 +0100 Subject: [PATCH] aco/ra: fix sub-dword get_reg_specified in some cases MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For example, v6b MIMG can have sdw_def_info={4, 6}. This now has similar behaviour as the DefInfo constructor. fossil-db (navi31): Totals from 5 (0.01% of 79395) affected shaders: CodeSize: 29460 -> 29408 (-0.18%); split: -0.29%, +0.11% Latency: 22133 -> 21934 (-0.90%); split: -2.51%, +1.61% InvThroughput: 2953 -> 2963 (+0.34%); split: -0.03%, +0.37% Copies: 410 -> 409 (-0.24%); split: -1.95%, +1.71% VALU: 3242 -> 3241 (-0.03%); split: -0.25%, +0.22% Signed-off-by: Rhys Perry Reviewed-by: Daniel Schürmann Fixes: 56345b8c610e ("aco: allow reading/writing upper halves/bytes when possible") Part-of: (cherry picked from commit 1e6741bf6b23a201af13b9368f06a2d8325c5dbb) --- .pick_status.json | 2 +- src/amd/compiler/aco_register_allocation.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 57b253a4694..7c59df6a146 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -684,7 +684,7 @@ "description": "aco/ra: fix sub-dword get_reg_specified in some cases", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "56345b8c610e06b2c6ccb0d0975e62f9a008e34e", "notes": null diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 867d8c6aff6..87a121ee32c 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -1403,8 +1403,9 @@ get_reg_specified(ra_ctx& ctx, const RegisterFile& reg_file, RegClass rc, return false; if (rc.is_subdword()) { - PhysReg test_reg; - test_reg.reg_b = reg.reg_b & ~(sdw_def_info.second - 1); + PhysReg test_reg = reg; + if (sdw_def_info.second > rc.bytes()) + test_reg.reg_b &= ~(align(sdw_def_info.first, sdw_def_info.second) - 1); if (reg_file.test(test_reg, sdw_def_info.second)) return false; } else {