From 0f535785bbd4dff95f5c228cdbbb517609a5751b Mon Sep 17 00:00:00 2001 From: Tony Wasserka Date: Wed, 2 Sep 2020 18:28:36 +0200 Subject: [PATCH] aco: Fix integer overflows when emitting parallel copies during RA MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 32-bit shifts were accidentally used before this change despite the intended output being 64 bits. This was observed when compiling Dolphin's ubershaders. Cc: mesa-stable Reviewed-by: Bas Nieuwenhuizen Reviewed-by: Daniel Schürmann Part-of: (cherry picked from commit 2182bbf84f0f19846a47f0438ec702f4d862731e) --- .pick_status.json | 2 +- src/amd/compiler/aco_register_allocation.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 16b39d83c18..31924803ca0 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2209,7 +2209,7 @@ "description": "aco: Fix integer overflows when emitting parallel copies during RA", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": null }, diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index 862b00d859b..2fb6655d24d 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -2235,11 +2235,11 @@ void register_allocation(Program *program, std::vector& live_out_per_bl if (!sgpr_operands_alias_defs) { unsigned reg = parallelcopy[i].first.physReg().reg(); unsigned size = parallelcopy[i].first.getTemp().size(); - sgpr_operands[reg / 64u] |= ((1u << size) - 1) << (reg % 64u); + sgpr_operands[reg / 64u] |= u_bit_consecutive64(reg % 64u, size); reg = parallelcopy[i].second.physReg().reg(); size = parallelcopy[i].second.getTemp().size(); - if (sgpr_operands[reg / 64u] & ((1u << size) - 1) << (reg % 64u)) + if (sgpr_operands[reg / 64u] & u_bit_consecutive64(reg % 64u, size)) sgpr_operands_alias_defs = true; } }