|
3 | 3 | use core::ascii::EscapeDefault; |
4 | 4 |
|
5 | 5 | use crate::fmt::{self, Write}; |
6 | | -#[cfg(not(all(target_arch = "x86_64", target_feature = "sse2")))] |
| 6 | +#[cfg(not(any( |
| 7 | + all(target_arch = "x86_64", target_feature = "sse2"), |
| 8 | + all(target_arch = "loongarch64", target_feature = "lsx") |
| 9 | +)))] |
7 | 10 | use crate::intrinsics::const_eval_select; |
8 | 11 | use crate::{ascii, iter, ops}; |
9 | 12 |
|
@@ -359,7 +362,10 @@ pub const fn is_ascii_simple(mut bytes: &[u8]) -> bool { |
359 | 362 | /// |
360 | 363 | /// If any of these loads produces something for which `contains_nonascii` |
361 | 364 | /// (above) returns true, then we know the answer is false. |
362 | | -#[cfg(not(all(target_arch = "x86_64", target_feature = "sse2")))] |
| 365 | +#[cfg(not(any( |
| 366 | + all(target_arch = "x86_64", target_feature = "sse2"), |
| 367 | + all(target_arch = "loongarch64", target_feature = "lsx") |
| 368 | +)))] |
363 | 369 | #[inline] |
364 | 370 | #[rustc_allow_const_fn_unstable(const_eval_select)] // fallback impl has same behavior |
365 | 371 | const fn is_ascii(s: &[u8]) -> bool { |
@@ -457,12 +463,15 @@ const fn is_ascii(s: &[u8]) -> bool { |
457 | 463 | ) |
458 | 464 | } |
459 | 465 |
|
460 | | -/// ASCII test optimized to use the `pmovmskb` instruction available on `x86-64` |
461 | | -/// platforms. |
| 466 | +/// ASCII test optimized to use the `pmovmskb` instruction on `x86-64` and the |
| 467 | +/// `vmskltz.b` instruction on `loongarch64`. |
462 | 468 | /// |
463 | 469 | /// Other platforms are not likely to benefit from this code structure, so they |
464 | 470 | /// use SWAR techniques to test for ASCII in `usize`-sized chunks. |
465 | | -#[cfg(all(target_arch = "x86_64", target_feature = "sse2"))] |
| 471 | +#[cfg(any( |
| 472 | + all(target_arch = "x86_64", target_feature = "sse2"), |
| 473 | + all(target_arch = "loongarch64", target_feature = "lsx") |
| 474 | +))] |
466 | 475 | #[inline] |
467 | 476 | const fn is_ascii(bytes: &[u8]) -> bool { |
468 | 477 | // Process chunks of 32 bytes at a time in the fast path to enable |
|
0 commit comments