From 21eafe30df5d5fa02a908e277add7adb7816ec4c Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 13 Dec 2019 16:59:54 +0000 Subject: [PATCH] aco: better handle neg/abs of sgprs MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit isel/label_instruction currently doesn't create these but we should probably check anyway. Signed-off-by: Rhys Perry Reviewed-By: Timur Kristóf Part-of: --- src/amd/compiler/aco_optimizer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index eef2532e3cd..68831a653a3 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -924,7 +924,8 @@ void label_instruction(opt_ctx &ctx, Block& block, aco_ptr& instr) break; } case aco_opcode::v_and_b32: /* abs */ - if (!instr->usesModifiers() && instr->operands[0].constantEquals(0x7FFFFFFF) && instr->operands[1].isTemp()) + if (!instr->usesModifiers() && instr->operands[0].constantEquals(0x7FFFFFFF) && + instr->operands[1].isTemp() && instr->operands[1].getTemp().type() == RegType::vgpr) ctx.info[instr->definitions[0].tempId()].set_abs(instr->operands[1].getTemp()); else ctx.info[instr->definitions[0].tempId()].set_bitwise(instr.get()); @@ -933,7 +934,7 @@ void label_instruction(opt_ctx &ctx, Block& block, aco_ptr& instr) if (!instr->usesModifiers() && instr->operands[0].constantEquals(0x80000000u) && instr->operands[1].isTemp()) { if (ctx.info[instr->operands[1].tempId()].is_neg()) { ctx.info[instr->definitions[0].tempId()].set_temp(ctx.info[instr->operands[1].tempId()].temp); - } else { + } else if (instr->operands[1].getTemp().type() == RegType::vgpr) { if (ctx.info[instr->operands[1].tempId()].is_abs()) { /* neg(abs(x)) */ instr->operands[1].setTemp(ctx.info[instr->operands[1].tempId()].temp); instr->opcode = aco_opcode::v_or_b32; -- 2.30.2