From 655c050119719e185ae41bdafb1e62d71ccc3069 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timur=20Krist=C3=B3f?= Date: Mon, 9 Mar 2020 17:07:41 +0100 Subject: [PATCH] aco: Fix combining DS additions in the optimizer. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Previously, it was calculated incorrectly for 64-bit writes and reads. Signed-off-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_optimizer.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index 95773c1205c..a18060f485b 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -816,12 +816,15 @@ void label_instruction(opt_ctx &ctx, Block& block, aco_ptr& instr) instr->opcode != aco_opcode::ds_swizzle_b32) { if (instr->opcode == aco_opcode::ds_write2_b32 || instr->opcode == aco_opcode::ds_read2_b32 || instr->opcode == aco_opcode::ds_write2_b64 || instr->opcode == aco_opcode::ds_read2_b64) { - if (offset % 4 == 0 && - ds->offset0 + (offset >> 2) <= 255 && - ds->offset1 + (offset >> 2) <= 255) { + unsigned mask = (instr->opcode == aco_opcode::ds_write2_b64 || instr->opcode == aco_opcode::ds_read2_b64) ? 0x7 : 0x3; + unsigned shifts = (instr->opcode == aco_opcode::ds_write2_b64 || instr->opcode == aco_opcode::ds_read2_b64) ? 3 : 2; + + if ((offset & mask) == 0 && + ds->offset0 + (offset >> shifts) <= 255 && + ds->offset1 + (offset >> shifts) <= 255) { instr->operands[i].setTemp(base); - ds->offset0 += offset >> 2; - ds->offset1 += offset >> 2; + ds->offset0 += offset >> shifts; + ds->offset1 += offset >> shifts; } } else { if (ds->offset0 + offset <= 65535) { -- 2.30.2