Skip to content

Commit 27fc967

Browse files
committed
Revert "[libc] Enable wide-read memory operations by default on Linux (#154602)"
This reverts commit c80d148.
1 parent 2cb7c46 commit 27fc967

File tree

3 files changed

+14
-25
lines changed

3 files changed

+14
-25
lines changed

libc/config/linux/config.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

libc/src/string/memory_utils/aarch64/inline_strlen.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
namespace LIBC_NAMESPACE_DECL {
1818

1919
namespace neon {
20-
[[maybe_unused]] LIBC_INLINE static size_t string_length(const char *src) {
20+
[[maybe_unused]] LIBC_INLINE size_t string_length(const char *src) {
2121
using Vector __attribute__((may_alias)) = uint8x8_t;
2222

2323
uintptr_t misalign_bytes = reinterpret_cast<uintptr_t>(src) % sizeof(Vector);
24-
const Vector *block_ptr =
25-
reinterpret_cast<const Vector *>(src - misalign_bytes);
24+
Vector *block_ptr = reinterpret_cast<Vector *>(src - misalign_bytes);
2625
Vector v = *block_ptr;
2726
Vector vcmp = vceqz_u8(v);
28-
uint64x1_t cmp_mask = vreinterpret_u64_u8(vcmp);
27+
uint64x1_t cmp_mask = vreinterpret_u64_s8(vcmp);
2928
uint64_t cmp = vget_lane_u64(cmp_mask, 0);
3029
cmp = cmp >> (misalign_bytes << 3);
3130
if (cmp)
@@ -35,7 +34,7 @@ namespace neon {
3534
++block_ptr;
3635
v = *block_ptr;
3736
vcmp = vceqz_u8(v);
38-
cmp_mask = vreinterpret_u64_u8(vcmp);
37+
cmp_mask = vreinterpret_u64_s8(vcmp);
3938
cmp = vget_lane_u64(cmp_mask, 0);
4039
if (cmp)
4140
return static_cast<size_t>(reinterpret_cast<uintptr_t>(block_ptr) -

libc/src/string/memory_utils/x86_64/inline_strlen.h

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,22 @@ namespace LIBC_NAMESPACE_DECL {
1818
namespace string_length_internal {
1919
// Return a bit-mask with the nth bit set if the nth-byte in block_ptr is zero.
2020
template <typename Vector, typename Mask>
21-
LIBC_INLINE static Mask compare_and_mask(const Vector *block_ptr);
21+
Mask CompareAndMask(const Vector *block_ptr);
2222

2323
template <typename Vector, typename Mask,
24-
decltype(compare_and_mask<Vector, Mask>)>
24+
decltype(CompareAndMask<Vector, Mask>)>
2525
size_t string_length_vector(const char *src) {
2626
uintptr_t misalign_bytes = reinterpret_cast<uintptr_t>(src) % sizeof(Vector);
2727

2828
const Vector *block_ptr =
2929
reinterpret_cast<const Vector *>(src - misalign_bytes);
30-
auto cmp = compare_and_mask<Vector, Mask>(block_ptr) >> misalign_bytes;
30+
auto cmp = CompareAndMask<Vector, Mask>(block_ptr) >> misalign_bytes;
3131
if (cmp)
3232
return cpp::countr_zero(cmp);
3333

3434
while (true) {
3535
block_ptr++;
36-
cmp = compare_and_mask<Vector, Mask>(block_ptr);
36+
cmp = CompareAndMask<Vector, Mask>(block_ptr);
3737
if (cmp)
3838
return static_cast<size_t>(reinterpret_cast<uintptr_t>(block_ptr) -
3939
reinterpret_cast<uintptr_t>(src) +
@@ -42,8 +42,7 @@ size_t string_length_vector(const char *src) {
4242
}
4343

4444
template <>
45-
LIBC_INLINE uint32_t
46-
compare_and_mask<__m128i, uint32_t>(const __m128i *block_ptr) {
45+
uint32_t CompareAndMask<__m128i, uint32_t>(const __m128i *block_ptr) {
4746
__m128i v = _mm_load_si128(block_ptr);
4847
__m128i z = _mm_setzero_si128();
4948
__m128i c = _mm_cmpeq_epi8(z, v);
@@ -53,14 +52,13 @@ compare_and_mask<__m128i, uint32_t>(const __m128i *block_ptr) {
5352
namespace sse2 {
5453
[[maybe_unused]] LIBC_INLINE size_t string_length(const char *src) {
5554
return string_length_vector<__m128i, uint32_t,
56-
compare_and_mask<__m128i, uint32_t>>(src);
55+
CompareAndMask<__m128i, uint32_t>>(src);
5756
}
5857
} // namespace sse2
5958

6059
#if defined(__AVX2__)
6160
template <>
62-
LIBC_INLINE uint32_t
63-
compare_and_mask<__m256i, uint32_t>(const __m256i *block_ptr) {
61+
uint32_t CompareAndMask<__m256i, uint32_t>(const __m256i *block_ptr) {
6462
__m256i v = _mm256_load_si256(block_ptr);
6563
__m256i z = _mm256_setzero_si256();
6664
__m256i c = _mm256_cmpeq_epi8(z, v);
@@ -70,23 +68,22 @@ compare_and_mask<__m256i, uint32_t>(const __m256i *block_ptr) {
7068
namespace avx2 {
7169
[[maybe_unused]] LIBC_INLINE size_t string_length(const char *src) {
7270
return string_length_vector<__m256i, uint32_t,
73-
compare_and_mask<__m256i, uint32_t>>(src);
71+
CompareAndMask<__m256i, uint32_t>>(src);
7472
}
7573
} // namespace avx2
7674
#endif
7775

7876
#if defined(__AVX512F__)
7977
template <>
80-
LIBC_INLINE __mmask64
81-
compare_and_mask<__m512i, __mmask64>(const __m512i *block_ptr) {
78+
__mmask64 CompareAndMask<__m512i, __mmask64>(const __m512i *block_ptr) {
8279
__m512i v = _mm512_load_si512(block_ptr);
8380
__m512i z = _mm512_setzero_si512();
8481
return _mm512_cmp_epu8_mask(z, v, _MM_CMPINT_EQ);
8582
}
8683
namespace avx512 {
8784
[[maybe_unused]] LIBC_INLINE size_t string_length(const char *src) {
8885
return string_length_vector<__m512i, __mmask64,
89-
compare_and_mask<__m512i, __mmask64>>(src);
86+
CompareAndMask<__m512i, __mmask64>>(src);
9087
}
9188
} // namespace avx512
9289
#endif

0 commit comments

Comments
 (0)