From eba8e2284bb76792ee5bcea249a91d51f99b383f Mon Sep 17 00:00:00 2001 From: eladash Date: Sat, 30 Mar 2019 13:59:30 +0300 Subject: [PATCH] SPU LLVM: Fix CFLTU Clamp properly result from both sides! TODO: Figure out whats different CreateFPToUi has from CFLTU and why it fails here. --- rpcs3/Emu/Cell/SPURecompiler.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 3bb3ced322..5a58e9d2d4 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -6257,8 +6257,10 @@ public: return; } + const auto _max = fsplat(std::exp2(32.f)); r.value = m_ir->CreateFPToUI(a.value, get_type()); - set_vr(op.rt, r & sext(fcmp(a, fsplat(0.)))); + r.value = m_ir->CreateSelect(m_ir->CreateFCmpUGE(a.value, _max.value), splat(-1).eval(m_ir), (r & sext(fcmp(a, fsplat(0.)))).eval(m_ir)); + set_vr(op.rt, r); } else { @@ -6272,8 +6274,10 @@ public: a = eval(a * s); value_t r; + const auto _max = fsplat(std::exp2(32.f)); r.value = m_ir->CreateFPToUI(a.value, get_type()); - set_vr(op.rt, r & ~(bitcast(a) >> 31)); + r.value = m_ir->CreateSelect(m_ir->CreateFCmpUGE(a.value, _max.value), splat(-1).eval(m_ir), (r & ~(bitcast(a) >> 31)).eval(m_ir)); + set_vr(op.rt, r); } }