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

Document vmmul Anomaly #2

Open
SK83RJOSH opened this issue Jan 21, 2024 · 1 comment
Open

Document vmmul Anomaly #2

SK83RJOSH opened this issue Jan 21, 2024 · 1 comment

Comments

@SK83RJOSH
Copy link

SK83RJOSH commented Jan 21, 2024

It appears that vmmul inexplicably flips the 2nd bit of it's rs parameter. As documented here and here. I'm fairly certain based on the psptoolchain patch, that it's the only instruction that has this anomaly, but who knows - maybe there's some other hidden oddities some where.

I figured you'd want to know, so you can update the documentation. 🙂

@davidgfnet
Copy link
Collaborator

Yeah we should clarify that!
The bit flip makes the rs parameter transposed (so M->E or E->M), right? That is due to the fact that the vmmul instruction does not actually multiply matrices (in the way that math defines it) but rather performs N*N vdot operations. The operations follow the same direction for both inputs, so this gives rs^T * rt (if I recall correctly). Therefore we "correct" the input to a more natural operation. This is indeed not very clear :P (However the pseudocode is correct and is tested correctly, since a direct encoding, using .word, is used, this is done to avoid binutils bugs).

I think more instructions existed in the official SDK, like vcmmul and vrmmul, variants that reorder registers and/or transpose matrices.

I will update the docs by adding some comment to explicitely mention that the "rs" register will be mangled by the assembler, since this is what we always did for binutils.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants