Repository navigation
Fix the lane order of eight MMI permutation instructions - #291
Open
VariableDeclared wants to merge 1 commit into
Open
VariableDeclared wants to merge 1 commit into
VariableDeclared wants to merge 1 commit into
Conversation
Checked against the EE Core Instruction Set Manual: Op Correct Was PEXEW swap w0 and w2 swapped w0/w1 and w2/w3 PEXCW swap w1 and w2 swapped the 64-bit halves PEXEH swap h0 and h2 in each doubleword swapped adjacent pairs PEXCH swap h1 and h2 in each doubleword swapped adjacent pairs PROT3W w0,w1,w2 <- w1,w2,w0, w3 kept rotated all four words PREVH reverse the halfwords of each doubleword reversed all eight PINTH rt low halfwords with rs HIGH halfwords used rs low halfwords PINTEH even halfwords of rt and rs used unpackhi PEXEW in particular is the common way to pull the z lane of a vector into the low word, so code that does it got the y lane instead (in one game this turned an angle-wrap loop into an infinite loop). The runtime macros are fixed, and the translator now emits the PS2_PEXEH/PEXCH/PREVH/PEXCW/PROT3W macros instead of its own inline shuffles. New unit tests check every lane of each instruction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I had checked the eight permutations independently against the EE Core Instruction Set Manual, a scalar, This also fixes #435 (PROT3W rotating all four words). Since #359 was merged this conflicts with main, but only in |
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.
Problem
Several MMI permutation instructions moved the wrong lanes. Checked against the EE Core Instruction Set Manual:
unpackhiSymptom
PEXEWis a common way for compiled code to move the z lane of a vector into the low word. With the wrong shuffle it got y instead; in one game an angle-normalisingwhile (a < -k) a += 2kloop then never terminated.Fix
PS2_PEXEW,PS2_PEXEH,PS2_PROT3W,PS2_PINTH,PS2_PINTEH, and addPS2_PEXCW,PS2_PEXCH,PS2_PREVHinps2_runtime_macros.h.Generated code has to be regenerated to pick this up.
Verification
PS2X_IOP_BUILD_TESTS=ON, ps2xTest) with CMake/Ninja, Release, macOS arm64.ps2x_tests: 448/448 pass. ps2xIOPctest: 4/4 pass.ps2_mmi_permutation_tests.cppchecks every output lane of each of the eight instructions.🤖 Generated with Claude Code