Skip to content

Commit

Permalink
fix: add comments before s390x vector operations
Browse files Browse the repository at this point in the history
Signed-off-by: iko1 <me@remotecpp.dev>
  • Loading branch information
iko1 committed Jun 13, 2023
1 parent 9d6e149 commit 40e785c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/core/detail/bitpacking.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,14 @@ static inline pair<const char*, uint8_t*> simd_variant2_pack(const char* ascii,
#ifdef __s390x__
bool validate_ascii_fast(const char* src, size_t len) {
size_t i = 0;
vector unsigned char has_error = vec_splat_s8(0);

// Initialize a vector in which all the elements are set to zero.
vector signed char has_error = vec_splat_s8(0);
if (len >= 16) {
for (; i <= len - 16; i += 16) {
vector unsigned char current_bytes = vec_load_len((signed char*)(src + i), 16);
// Load 16 bytes from buffer into a vector.
vector signed char current_bytes = vec_load_len((signed char*)(src + i), 16);
// Perform a bitwise OR operation between the current and the previously loaded contents.
has_error = vec_orc(has_error, current_bytes);
}
}
Expand All @@ -130,9 +134,10 @@ bool validate_ascii_fast(const char* src, size_t len) {
for (; i < len; i++) {
tail_has_error |= src[i];
}

error_mask |= (tail_has_error & 0x80);

return !error_mask;
return (error_mask < 0x80);
}
#else
bool validate_ascii_fast(const char* src, size_t len) {
Expand Down

0 comments on commit 40e785c

Please sign in to comment.