Commit 4228b53
authored
Rollup merge of rust-lang#146699 - heiher:is-ascii-lsx, r=Mark-Simulacrum
Add `is_ascii` function optimized for LoongArch64 for [u8]
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 |1 file changed
+14
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
7 | 10 | | |
8 | 11 | | |
9 | 12 | | |
| |||
359 | 362 | | |
360 | 363 | | |
361 | 364 | | |
362 | | - | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
363 | 369 | | |
364 | 370 | | |
365 | 371 | | |
| |||
457 | 463 | | |
458 | 464 | | |
459 | 465 | | |
460 | | - | |
461 | | - | |
| 466 | + | |
| 467 | + | |
462 | 468 | | |
463 | 469 | | |
464 | 470 | | |
465 | | - | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
466 | 475 | | |
467 | 476 | | |
468 | 477 | | |
| |||
0 commit comments