Skip to content

Conversation

heiher
Copy link
Contributor

@heiher heiher commented Sep 18, 2025

Similar to x86_64, on LoongArch64 we use the vmskltz.b instruction to test the high bit in a lane.

For longer input cases, the performance improvement is significant. For unaligned cases close to 32 bytes in length, there's some regression, but it seems acceptable.

core benches (MB/s) Before After %
ascii::is_ascii::short::case00_libcore 1000 1000 0.00
ascii::is_ascii::medium::case00_libcore 8000 8000 0.00
ascii::is_ascii::long::case00_libcore 183947 436875 +137.50
ascii::is_ascii::unaligned_head_medium::case00_libcore 7750 2818 -63.64
ascii::is_ascii::unaligned_head_long::case00_libcore 317681 436812 +37.50
ascii::is_ascii::unaligned_tail_medium::case00_libcore 7750 3444 -55.56
ascii::is_ascii::unaligned_tail_long::case00_libcore 155311 436812 +181.25
ascii::is_ascii::unaligned_both_medium::case00_libcore 7500 3333 -55.56
ascii::is_ascii::unaligned_both_long::case00_libcore 174700 436750 +150.00

Similar to x86_64, on LoongArch64 we use the `vmskltz.b` instruction
to test the high bit in a lane.

For longer input cases, the performance improvement is significant.
For unaligned cases close to 32 bytes in length, there's some regression,
but it seems acceptable.

| core benches (MB/s)                                    | Before | After  | %       |
|--------------------------------------------------------|--------|--------|---------|
| ascii::is_ascii::short::case00_libcore                 | 1000   | 1000   | 0.00    |
| ascii::is_ascii::medium::case00_libcore                | 8000   | 8000   | 0.00    |
| ascii::is_ascii::long::case00_libcore                  | 183947 | 436875 | +137.50 |
| ascii::is_ascii::unaligned_head_medium::case00_libcore | 7750   | 2818   | -63.64  |
| ascii::is_ascii::unaligned_head_long::case00_libcore   | 317681 | 436812 | +37.50  |
| ascii::is_ascii::unaligned_tail_medium::case00_libcore | 7750   | 3444   | -55.56  |
| ascii::is_ascii::unaligned_tail_long::case00_libcore   | 155311 | 436812 | +181.25 |
| ascii::is_ascii::unaligned_both_medium::case00_libcore | 7500   | 3333   | -55.56  |
| ascii::is_ascii::unaligned_both_long::case00_libcore   | 174700 | 436750 | +150.00 |
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 18, 2025
@rustbot
Copy link
Collaborator

rustbot commented Sep 18, 2025

r? @scottmcm

rustbot has assigned @scottmcm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants