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