From a2e8e3090c992402fb8723761319cb03e4b5f9ef Mon Sep 17 00:00:00 2001 From: Malcolm Jestadt Date: Sun, 17 Jan 2021 03:45:56 -0500 Subject: [PATCH] SPU LLVM: Optimize FSM following comparison - FSM following a comparison instruction can be optimized to a single shuffle instruction --- rpcs3/Emu/Cell/SPURecompiler.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 5dd6730316..460c2bf00d 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -6463,6 +6463,23 @@ public: void FSM(spu_opcode_t op) { + // FSM following a comparison instruction + if (match_vr(op.ra, [&](auto c, auto MP) + { + using VT = typename decltype(MP)::type; + + if (auto [ok, x] = match_expr(c, sext(match]>())); ok) + { + set_vr(op.rt, (splat_scalar(c))); + return true; + } + + return false; + })) + { + return; + } + const auto v = extract(get_vr(op.ra), 3); const auto m = bitcast(trunc(v)); set_vr(op.rt, sext(m));