From a2f7b7bfa4987c102892793ab7c7483fcb8050a0 Mon Sep 17 00:00:00 2001 From: ijl Date: Wed, 14 Feb 2024 02:30:10 +0000 Subject: [PATCH] impl_format_simd!() lift create from loop, rotate left --- .github/workflows/linux.yaml | 3 ++- src/serialize/writer/simd.rs | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.github/workflows/linux.yaml b/.github/workflows/linux.yaml index b7ee3df9..4f7340a2 100644 --- a/.github/workflows/linux.yaml +++ b/.github/workflows/linux.yaml @@ -217,7 +217,8 @@ jobs: { arch: 's390x', cflags: '-O2 -flto -march=z10', - features: 'no-panic,unstable-simd,yyjson', + # no unstable-simd as rotate_elements_left() causes exit 125 in at least QEMU + features: 'no-panic,yyjson', rustflags: '-Z mir-opt-level=4 -C target-cpu=z10 -D warnings', target: 's390x-unknown-linux-gnu', }, diff --git a/src/serialize/writer/simd.rs b/src/serialize/writer/simd.rs index 94a42ac8..82a12187 100644 --- a/src/serialize/writer/simd.rs +++ b/src/serialize/writer/simd.rs @@ -64,14 +64,14 @@ macro_rules! impl_format_simd { } } + let mut v = if unlikely!(is_cross_page!(sptr)) { + let mut v = StrVector::default(); + v.as_mut_array()[..nb].copy_from_slice(core::slice::from_raw_parts(sptr, nb)); + v + } else { + StrVector::from_slice(core::slice::from_raw_parts(sptr, STRIDE)) + }; while nb > 0 { - let v = if unlikely!(is_cross_page!(sptr)) { - let mut v = StrVector::default(); - v.as_mut_array()[..nb].copy_from_slice(core::slice::from_raw_parts(sptr, nb)); - v - } else { - StrVector::from_slice(core::slice::from_raw_parts(sptr, STRIDE)) - }; v.copy_to_slice(core::slice::from_raw_parts_mut(dptr, STRIDE)); let mut mask = (v.simd_eq(blash) | v.simd_eq(quote) | v.simd_lt(x20)).to_bitmask() as u32 @@ -82,7 +82,13 @@ macro_rules! impl_format_simd { break; } else { let cn = mask.trailing_zeros() as usize; + let nb_start = nb; impl_escape_unchecked!(sptr, dptr, nb, mask, cn); + let mut consumed = nb_start - nb; + while consumed != 0 { + v = v.rotate_elements_left::<1>(); + consumed -= 1; + } } }