Repository navigation
fix(recomp): give the MMI HI/LO family both pipelines' registers - #322
Open
abilliontokens wants to merge 1 commit into
Open
abilliontokens wants to merge 1 commit into
abilliontokens wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Defect
The R5900's MMI multiply/divide family feeds two HI/LO pipeline register pairs —
hi/lo(pipeline 0) andhi1/lo1(pipeline 1) — andR5900Contextalready carrieshi1/lo1forMULT1/DIV1. The MMI translation ignored the second pair and collapsed everything into one 64-bit accumulator with the wrong lanes:PMULTW/PMULTUWsummed all four 32×32 products into one 64-bitHI:LO(hardware:lo/hi= product of words 0,lo1/hi1= product of words 2; rd gets both 64-bit products).PMADDW/PMSUBW/PMADDUWaccumulated into that same single pair; hardware accumulates pipeline 0 fromHI:LOand pipeline 1 fromHI1:LO1(PCSX2'sMMI.cppincludes its documented high-wordtemp2 / 4294967295rounding and, for PMADDW pipeline 0, the "division voodoo"+0x70000000term).PDIVW/PDIVUW/PDIVBWdivided only word 0 (PDIVBW: only one divisor); hardware divides both word pairs (PDIVBW: every word byrt.h0, quotient inLO/LO1, remainder inHI/HI1).PMFHI/PMFLOreturned only the pipeline-0 register.PMFHL.*was built from one pair with wrongunpack/packsorders (SLWdid not clamp the 64-bit pairs,LH/SHtook the wrong halfwords);PMTHLhandled onlysa=0and clobbered both 32-bit halves of each HI/LO.PMULTH/PMADDH/PMSUBH/PHMADH/PHMSBHrouted halfword products into the wrong slots (PHMSBHmissed the documented~second-tempupper-word quirk).Any title using the MMI integer DSP idioms (audio mixing, geometry setup, fixed-point filters) gets wrong data on every one of these.
Fix
A
ps2_mmi_*helper family inps2_runtime_macros.h, semantics taken from PCSX2's interpreter (pcsx2/MMI.cpp) quirk-for-quirk, using bothhi/loandhi1/lo1; the translator emits one call per instruction.ps2_u64_to_epi64_pairand the oldPS2_PMFHL_*macros are removed. No permutation instruction is touched here (see #291 for those).Generated code must be regenerated to pick this up.
Evidence
PS2MmiHiLosuite, 45 cases: every helper against known answers derived from PCSX2's code with a distinct pattern in every lane (both pipelines, both sa forms,0x80000000 / -1, divide-by-zero results, the PMADDW rounding/voodoo terms,PHMSBH's inverted upper word, rd suppression for PDIV*,$0destinations). All fail onmain.ps2x_tests: Correction (2026-10-16): an earlier version of this description saidEE scheduler selects absolute priority then FIFOalso fails on pristinemain. That was wrong. Our local MSVC build was configured with-DCMAKE_CXX_FLAGS=-msse4.1, which replaces CMake's default flags and so drops/EHsc, and that test failed only in that build. With default flags the suite passes onmain: upstream CI is green oneb8688b(run 38574762065). Theps2x_teststotals measured in that build are withdrawn until re-run; every comparison above used the same build on both sides. TestSuiteRepair found the misconfiguration.