From a2253e840f28c06546cdd8231e05be94e7c4ea2b Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 28 May 2018 22:30:23 +0300 Subject: [PATCH] SPU LLVM: fix *QBI instructions (UB) Improve codegen at the cost of unnecessary shuffle, use u64[2] --- rpcs3/Emu/Cell/SPURecompiler.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 4b7b0bb089..9d1ae5f703 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -2021,23 +2021,23 @@ public: void ROTQBI(spu_opcode_t op) { - const auto a = get_vr(op.ra); - const auto b = zshuffle(get_vr(op.rb) & 0x7, 3, 3, 3, 3); - set_vr(op.rt, a << b | zshuffle(a, 3, 0, 1, 2) >> (32 - b)); + const auto a = get_vr(op.ra); + const auto b = eval((get_vr(op.rb) >> 32) & 0x7); + set_vr(op.rt, a << zshuffle(b, 1, 1) | zshuffle(a, 1, 0) >> 56 >> zshuffle(8 - b, 1, 1)); } void ROTQMBI(spu_opcode_t op) { - const auto a = get_vr(op.ra); - const auto b = zshuffle(-get_vr(op.rb) & 0x7, 3, 3, 3, 3); - set_vr(op.rt, a >> b | zshuffle(a, 1, 2, 3, 4) << (32 - b)); + const auto a = get_vr(op.ra); + const auto b = eval(-(get_vr(op.rb) >> 32) & 0x7); + set_vr(op.rt, a >> zshuffle(b, 1, 1) | zshuffle(a, 1, 2) << 56 << zshuffle(8 - b, 1, 1)); } void SHLQBI(spu_opcode_t op) { - const auto a = get_vr(op.ra); - const auto b = zshuffle(get_vr(op.rb) & 0x7, 3, 3, 3, 3); - set_vr(op.rt, a << b | zshuffle(a, 4, 0, 1, 2) >> (32 - b)); + const auto a = get_vr(op.ra); + const auto b = eval((get_vr(op.rb) >> 32) & 0x7); + set_vr(op.rt, a << zshuffle(b, 1, 1) | zshuffle(a, 2, 0) >> 56 >> zshuffle(8 - b, 1, 1)); } void ROTQBY(spu_opcode_t op)