From 796b3319e6171a152e41e9719b42dbddf20e2957 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Fri, 27 Mar 2020 18:36:38 -0300 Subject: shader/lea: Remove const and use move when possible --- src/video_core/shader/decode/arithmetic_integer.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'src/video_core') diff --git a/src/video_core/shader/decode/arithmetic_integer.cpp b/src/video_core/shader/decode/arithmetic_integer.cpp index 2fe787d6f..5d546ddec 100644 --- a/src/video_core/shader/decode/arithmetic_integer.cpp +++ b/src/video_core/shader/decode/arithmetic_integer.cpp @@ -235,34 +235,30 @@ u32 ShaderIR::DecodeArithmeticInteger(NodeBlock& bb, u32 pc) { case OpCode::Id::LEA_IMM: case OpCode::Id::LEA_RZ: case OpCode::Id::LEA_HI: { - const auto [op_a, op_b, op_c] = [&]() -> std::tuple { + auto [op_a, op_b, op_c] = [&]() -> std::tuple { switch (opcode->get().GetId()) { case OpCode::Id::LEA_R2: { return {GetRegister(instr.gpr20), GetRegister(instr.gpr39), Immediate(static_cast(instr.lea.r2.entry_a))}; } - case OpCode::Id::LEA_R1: { const bool neg = instr.lea.r1.neg != 0; return {GetOperandAbsNegInteger(GetRegister(instr.gpr8), false, neg, true), GetRegister(instr.gpr20), Immediate(static_cast(instr.lea.r1.entry_a))}; } - case OpCode::Id::LEA_IMM: { const bool neg = instr.lea.imm.neg != 0; return {Immediate(static_cast(instr.lea.imm.entry_a)), GetOperandAbsNegInteger(GetRegister(instr.gpr8), false, neg, true), Immediate(static_cast(instr.lea.imm.entry_b))}; } - case OpCode::Id::LEA_RZ: { const bool neg = instr.lea.rz.neg != 0; return {GetConstBuffer(instr.lea.rz.cb_index, instr.lea.rz.cb_offset), GetOperandAbsNegInteger(GetRegister(instr.gpr8), false, neg, true), Immediate(static_cast(instr.lea.rz.entry_a))}; } - case OpCode::Id::LEA_HI: default: UNIMPLEMENTED_MSG("Unhandled LEA subinstruction: {}", opcode->get().GetName()); @@ -275,12 +271,10 @@ u32 ShaderIR::DecodeArithmeticInteger(NodeBlock& bb, u32 pc) { UNIMPLEMENTED_IF_MSG(instr.lea.pred48 != static_cast(Pred::UnusedIndex), "Unhandled LEA Predicate"); - const Node shifted_c = - Operation(OperationCode::ILogicalShiftLeft, NO_PRECISE, Immediate(1), op_c); - const Node mul_bc = Operation(OperationCode::IMul, NO_PRECISE, op_b, shifted_c); - const Node value = Operation(OperationCode::IAdd, NO_PRECISE, op_a, mul_bc); - - SetRegister(bb, instr.gpr0, value); + Node shifted_c = Operation(OperationCode::ILogicalShiftLeft, Immediate(1), std::move(op_c)); + Node mul_bc = Operation(OperationCode::IMul, std::move(op_b), std::move(shifted_c)); + Node value = Operation(OperationCode::IAdd, std::move(op_a), std::move(mul_bc)); + SetRegister(bb, instr.gpr0, std::move(value)); break; } -- cgit v1.2.3 From 523a709bf1382419495035161c67d5e8dd3e2556 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Fri, 27 Mar 2020 18:37:18 -0300 Subject: shader/lea: Fix op_a and op_b usages They were swapped. --- src/video_core/shader/decode/arithmetic_integer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/video_core') diff --git a/src/video_core/shader/decode/arithmetic_integer.cpp b/src/video_core/shader/decode/arithmetic_integer.cpp index 5d546ddec..41ddc6221 100644 --- a/src/video_core/shader/decode/arithmetic_integer.cpp +++ b/src/video_core/shader/decode/arithmetic_integer.cpp @@ -272,8 +272,8 @@ u32 ShaderIR::DecodeArithmeticInteger(NodeBlock& bb, u32 pc) { "Unhandled LEA Predicate"); Node shifted_c = Operation(OperationCode::ILogicalShiftLeft, Immediate(1), std::move(op_c)); - Node mul_bc = Operation(OperationCode::IMul, std::move(op_b), std::move(shifted_c)); - Node value = Operation(OperationCode::IAdd, std::move(op_a), std::move(mul_bc)); + Node mul_bc = Operation(OperationCode::IMul, std::move(op_a), std::move(shifted_c)); + Node value = Operation(OperationCode::IAdd, std::move(op_b), std::move(mul_bc)); SetRegister(bb, instr.gpr0, std::move(value)); break; -- cgit v1.2.3 From 5300a918c60243ad3f3f9a145f0c8f495738e79f Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Sat, 28 Mar 2020 03:55:04 -0300 Subject: shader/lea: Simplify generated LEA code --- src/video_core/shader/decode/arithmetic_integer.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/video_core') diff --git a/src/video_core/shader/decode/arithmetic_integer.cpp b/src/video_core/shader/decode/arithmetic_integer.cpp index 41ddc6221..0f4c3103a 100644 --- a/src/video_core/shader/decode/arithmetic_integer.cpp +++ b/src/video_core/shader/decode/arithmetic_integer.cpp @@ -271,9 +271,8 @@ u32 ShaderIR::DecodeArithmeticInteger(NodeBlock& bb, u32 pc) { UNIMPLEMENTED_IF_MSG(instr.lea.pred48 != static_cast(Pred::UnusedIndex), "Unhandled LEA Predicate"); - Node shifted_c = Operation(OperationCode::ILogicalShiftLeft, Immediate(1), std::move(op_c)); - Node mul_bc = Operation(OperationCode::IMul, std::move(op_a), std::move(shifted_c)); - Node value = Operation(OperationCode::IAdd, std::move(op_b), std::move(mul_bc)); + Node value = Operation(OperationCode::ILogicalShiftLeft, std::move(op_a), std::move(op_c)); + value = Operation(OperationCode::IAdd, std::move(op_b), std::move(value)); SetRegister(bb, instr.gpr0, std::move(value)); break; -- cgit v1.2.3