47 Commits
Author SHA1 Message Date
bmdhacks 45b4197bee Fix: PMADDW/PMSUBW accumulate into one 64-bit value, not two 32-bit halves
Both the interpreter and the arm64 recompiler modelled each PMADDW/PMSUBW
lane as two independent 32-bit accumulations. That loses the carry between
LO and HI, needs a truncating `/ 0xFFFFFFFF` where an arithmetic shift
belongs, grew a +0x70000000 lane-0 addend to compensate, and leaves LO
sign-extended from the wrapped intermediate rather than from the
architectural result. The x86 recompiler has always done it correctly
(recPMADDW: PMULDQ + PADDQ + PMOVSXDQ against the packed accumulator), so
the three engines disagreed; this brings the other two into line with it.

Scored against the 64 ps2autotests PMADDW/PMSUBW captures, which preset
HI/LO to nonzero values and so make the width of the accumulate observable:

  two 32-bit halves + errata          54/64
  packed 64-bit accumulate            64/64

The errata components are not separable. Reintroducing any one of them
alone into the corrected model scores far worse than leaving all three in:

  packed + voodoo addend              52/64
  packed + truncating divide           3/64
  packed + carry dropped from HI      33/64

The truncating divide's off-by-one very nearly cancels the missing carry
on these operands, which is why the shipping code only lost 10 cases. A
partial fix here would have been much worse than none.

On arm64 the correct form is also the smaller one: Smull plus a 64-bit
add against the spliced accumulator replaces the lane splitting, the SDIV
by 0xFFFFFFFF and the whole conditional-addend block, and Rd.UD[dd] turns
out to be the raw result. Verified bidirectionally: reverting either
engine alone leaves 7 tests failing, since h.Run() auto-diffs the JIT
against the interpreter.

Tests: the six EeRecMmi vectors that pinned the errata are rewritten to
pin the carry, the borrow, the per-half sign extension and the absence of
the lane-0 addend; all six fail on the unpatched baseline. The
PMADDW/PMSUBW allowance in EeMmiConsoleConformance is deleted, so all 64
cases now assert normally.

Also corrects a comment in iMMI-arm64.cpp claiming MMI2_RECOMPILE is
never defined -- Config.h:1650 defines it unconditionally, which makes
that part of pcsx2/x86/iMMI.cpp the shipping x86 implementation rather
than dead reference code.

Idea by pstef.
2026-08-02 17:03:02 -07:00
SternXD d983b2b066 Copyright: Change year from 2002-2025 to 2002-2026 2026-01-15 00:22:32 +01:00
TheTechnician27 23fd57f641 Copyright: Change year from 2002-2024 to 2002-2025 2025-01-20 05:07:26 +01:00
GovanifY 132431b7c8 headers: relicense to GPL-3.0+
also update to 2024 while i'm at it
2024-07-30 17:17:13 -04:00
Stenzek d9abe10308 Misc: Remove explicit PCH include, switch to SPDX 2023-12-24 14:03:14 +10:00
Stenzek 2b4c7d12b6 Common: Merge MathUtils.h into BitUtils.h 2023-07-23 21:52:36 +10:00
TellowKrinkle 738c8cb630 Core: Remove trailing whitespace from all files 2022-09-16 00:52:28 -05:00
kojin 8fdaaa2eab common: reorganize 2021-09-04 18:28:07 -04:00
Dylan Smit 65ee46c0fb misc: Added the PlayStation name properly. (#3915) 2020-12-06 10:27:51 +01:00
refractionpcsx2 d520f3852b Missed some more code from testing.
I do know what I'm doing I swear
2018-09-04 20:52:17 +01:00
refractionpcsx2 50e3474b60 Missed a debug log. 2018-09-04 20:51:07 +01:00
refractionpcsx2 3c5fad7ef6 Reverted shift register stuff back to how it was, my changes made no difference now and it was slightly more optimal before.
Also fixed spaces (blame PSI :P )
2018-09-04 20:45:28 +01:00
refractionpcsx2 f7fb0f686b Fixed MFSA/MTSA, of course there's a game that abuses it (Rayman 3) 2018-09-04 20:26:36 +01:00
refractionpcsx2 8b0114596b Just adding some comments to MMI fix. 2018-07-31 18:48:51 +01:00
refractionpcsx2 1e0b0605a6 Corrected MMI PMADDW and PMSUBW on the Interpreters thanks to DobieStation for finding the fix 2018-07-31 18:45:32 +01:00
refractionpcsx2 69888e5ab0 EE Rec/Int: Removed micro optimisation in QFSRV/MSTAB/MSTAH. Reverted functionality to match the documentation. There were some scenarios that weren't really accounted for, like developers doing what they're told not to do. 2018-07-15 13:14:46 +01:00
Huud c56ac2cf3e PCSX2: Remove Unused And Unneeded Argument. (#1799)
EE interpeter: remove unused argument

rdd is neither used, nor needed. It appears it was there to pass the _Rd_ word to write to, but the writing was moved to PHMSBH() to have one "if (_Rd_)".

Add a note on undefined behavior
2017-02-01 11:30:41 +01:00
Gregory Hainaut 46a2f6ed24 interpreter: fix a subtle bug in a QFSRV
Math is correct but a shift of 64 bits is illegal in x86 because the cl register is masked

From the x86 spec:
    The destination operand can be a register or a memory location. The count operand can be an immediate value or
    the CL register. The count is masked to 5 bits (or 6 bits if in 64-bit mode and REX.W is used). The count range is
    limited to 0 to 31 (or 63 if 64-bit mode and REX.W is used). A special opcode encoding is provided for a count of 1.
2016-01-12 19:29:10 +01:00
refractionpcsx2 5b4eb65e68 eeInt: Fix logically dead code in PMFLH.
-Coverity CID 146817: In R5900::​Interpreter::​OpcodeImpl::​MMI::​PMFHL(): Code can never be reached because of a logical contradiction (CWE-561)
-This code is used by both the Interpreter and Recompiler, however it was probably never checked because nothing much uses it. Out of 248 games, it was called 0 times.
2015-10-04 13:34:37 +01:00
Jonathan Li 0a0008cf97 Rename Utilities/Math.h to Utilities/MathUtils.h
Math.h conflicts with <math.h> on Visual Studio and causes the utilities
project to fail. Rename it to MathUtils.h instead.
2015-08-09 22:41:18 +01:00
Miguel A. Colón Vélez 1cb47f3c80 Fix the messy revert.
Because someone had to do it.
2015-08-09 10:01:56 -04:00
refractionpcsx2 72b828ef0d Finish previous revert as TortoiseGit failed epicly at it. 2015-06-10 10:11:06 +01:00
Sacha 5287de930b Create a Math.h utility. Use it for count leading sign bits, used in MMI. 2014-08-28 00:42:53 +10:00
ramapcsx2 c47e1ed6e9 Couple clarifications and fixed warnings.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4367 96395faa-99c1-11dd-bbfe-3dabce05a288
2011-02-26 03:20:58 +00:00
cottonvibes 807bd9659c pcsx2 mmi: apparently msvc does an unsigned compare jump when you have:
int src; if (src < 0xffff8000) {}
so solution is either use (int)0xffff8000 or -0x8000...
it also doesn't seem to print out warnings about this either D:

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3712 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-09-01 02:03:10 +00:00