SPU LLVM: Recognize ROTYQBYI and ROTQBI rotation pattern - #16409
Merged
Conversation
Contributor
|
do you have some stats about the improvements compared to current implementation? |
Member
Author
It's not going to be a large improvement overall. I found the pattern while looking at hotspots in Dark Souls. Maybe some game benefits a lot. |
elad335
reviewed
Dec 19, 2024
| { | ||
| const auto b32 = get_vr<s32[4]>(op.rb); | ||
| // Is the rotate less than 31 bits? | ||
| if (auto k = get_known_bits(b32); !!(k.Zero & 0x60)) |
Contributor
There was a problem hiding this comment.
It was checking for any of them being 0 which is wrong.
Suggested change
| if (auto k = get_known_bits(b32); !!(k.Zero & 0x60)) | |
| if (auto k = get_known_bits(b32); (~k.Zero & 0x60) == 0) |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
ROTQBYBI shifts a vector by bytes, and ROTQBI shifts a vector by bits. We can recognize this pattern and shift by bytes and bits at the same time. Turns into just 1 instruction with AVX-512 (VPSHRDVD), but the AVX2 solution is also faster than before as well.
AVX-512

Before:
After:

AVX2

Before:
After:
