Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPU LLVM: Handle SHUFB special cases with a lookup table #11257

Merged
merged 2 commits into from
Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions rpcs3/Emu/Cell/SPURecompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8572,8 +8572,13 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
return;
}

// (TODO: implement via known-bits-lookup) Check whether shuffle mask doesn't contain fixed value selectors
const auto [perm_only, dummy1] = match_expr(c, match<u8[16]>() & 31);
// Check whether shuffle mask doesn't contain fixed value selectors
bool perm_only = false;

if (auto k = get_known_bits(c); !!(k.Zero & 0x80))
{
perm_only = true;
}

const auto a = get_vr<u8[16]>(op.ra);
const auto b = get_vr<u8[16]>(op.rb);
Expand All @@ -8599,7 +8604,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
return;
}

const auto x = avg(noncast<u8[16]>(sext<s8[16]>((c & 0xc0) == 0xc0)), noncast<u8[16]>(sext<s8[16]>((c & 0xe0) == 0xc0)));
const auto x = pshufb(build<u8[16]>(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x80), (c >> 4));
const auto ax = pshufb(as, c);
const auto bx = pshufb(bs, c);

Expand All @@ -8615,7 +8620,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
if (data == v128::from8p(data._u8[0]))
{
// See above
const auto x = avg(noncast<u8[16]>(sext<s8[16]>((c & 0xc0) == 0xc0)), noncast<u8[16]>(sext<s8[16]>((c & 0xe0) == 0xc0)));
const auto x = pshufb(build<u8[16]>(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x80), (c >> 4));
const auto ax = pshufb(as, c);

if (perm_only)
Expand All @@ -8634,7 +8639,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
if (data == v128::from8p(data._u8[0]))
{
// See above
const auto x = avg(noncast<u8[16]>(sext<s8[16]>((c & 0xc0) == 0xc0)), noncast<u8[16]>(sext<s8[16]>((c & 0xe0) == 0xc0)));
const auto x = pshufb(build<u8[16]>(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x80), (c >> 4));
const auto bx = pshufb(bs, c);

if (perm_only)
Expand Down Expand Up @@ -8662,7 +8667,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator
return;
}

const auto x = avg(noncast<u8[16]>(sext<s8[16]>((c & 0xc0) == 0xc0)), noncast<u8[16]>(sext<s8[16]>((c & 0xe0) == 0xc0)));
const auto x = pshufb(build<u8[16]>(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x80), (c >> 4));
const auto cr = eval(c ^ 0xf);
const auto ax = pshufb(a, cr);
const auto bx = pshufb(b, cr);
Expand Down