[libc-commits] [libc] 56ab6f7 - [libc][NFC] Fix lax vector conversion for aarch64

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Tue Dec 27 02:17:02 PST 2022


Author: Guillaume Chatelet
Date: 2022-12-27T10:16:37Z
New Revision: 56ab6f783bdd24b8d096bb96b7c8c0fb9a8d1e7c

URL: https://github.com/llvm/llvm-project/commit/56ab6f783bdd24b8d096bb96b7c8c0fb9a8d1e7c
DIFF: https://github.com/llvm/llvm-project/commit/56ab6f783bdd24b8d096bb96b7c8c0fb9a8d1e7c.diff

LOG: [libc][NFC] Fix lax vector conversion for aarch64

Added: 
    

Modified: 
    libc/src/string/memory_utils/op_aarch64.h

Removed: 
    


################################################################################
diff  --git a/libc/src/string/memory_utils/op_aarch64.h b/libc/src/string/memory_utils/op_aarch64.h
index 57f407b191f47..780191902f7ad 100644
--- a/libc/src/string/memory_utils/op_aarch64.h
+++ b/libc/src/string/memory_utils/op_aarch64.h
@@ -84,7 +84,7 @@ template <size_t Size> struct Bcmp {
       uint8x16_t a = vld1q_u8(_p1);
       uint8x16_t n = vld1q_u8(_p2);
       uint8x16_t an = veorq_u8(a, n);
-      uint32x2_t an_reduced = vqmovn_u64(an);
+      uint32x2_t an_reduced = vqmovn_u64(vreinterpretq_u64_u8(an));
       return vmaxv_u32(an_reduced);
     } else if constexpr (Size == 32) {
       auto _p1 = as_u8(p1);
@@ -101,7 +101,7 @@ template <size_t Size> struct Bcmp {
       // going from 2x64b to 2x32b. Second, compute the max of the 2x32b to get
       // a single 32 bit nonzero value if a mismatch occurred.
       uint8x16_t anbo = vorrq_u8(an, bo);
-      uint32x2_t anbo_reduced = vqmovn_u64(anbo);
+      uint32x2_t anbo_reduced = vqmovn_u64(vreinterpretq_u64_u8(anbo));
       return vmaxv_u32(anbo_reduced);
     } else if constexpr ((Size % BlockSize) == 0) {
       for (size_t offset = 0; offset < Size; offset += BlockSize)
@@ -125,11 +125,11 @@ template <size_t Size> struct Bcmp {
       uint8x16_t b = vld1q_u8(_p1 + count - 16);
       uint8x16_t n = vld1q_u8(_p2);
       uint8x16_t o = vld1q_u8(_p2 + count - 16);
-      uint8x16_t an = veorq_s8(a, n);
-      uint8x16_t bo = veorq_s8(b, o);
+      uint8x16_t an = veorq_u8(a, n);
+      uint8x16_t bo = veorq_u8(b, o);
       // anbo = (a ^ n) | (b ^ o)
-      uint8x16_t anbo = vorrq_s8(an, bo);
-      uint32x2_t anbo_reduced = vqmovn_u64(anbo);
+      uint8x16_t anbo = vorrq_u8(an, bo);
+      uint32x2_t anbo_reduced = vqmovn_u64(vreinterpretq_u64_u8(anbo));
       return vmaxv_u32(anbo_reduced);
     } else if constexpr (Size == 32) {
       auto _p1 = as_u8(p1);
@@ -142,12 +142,12 @@ template <size_t Size> struct Bcmp {
       uint8x16_t o = vld1q_u8(_p2 + 16);
       uint8x16_t p = vld1q_u8(_p2 + count - 16);
       uint8x16_t q = vld1q_u8(_p2 + count - 32);
-      uint8x16_t an = veorq_s8(a, n);
-      uint8x16_t bo = veorq_s8(b, o);
-      uint8x16_t cp = veorq_s8(c, p);
-      uint8x16_t dq = veorq_s8(d, q);
-      uint8x16_t anbo = vorrq_s8(an, bo);
-      uint8x16_t cpdq = vorrq_s8(cp, dq);
+      uint8x16_t an = veorq_u8(a, n);
+      uint8x16_t bo = veorq_u8(b, o);
+      uint8x16_t cp = veorq_u8(c, p);
+      uint8x16_t dq = veorq_u8(d, q);
+      uint8x16_t anbo = vorrq_u8(an, bo);
+      uint8x16_t cpdq = vorrq_u8(cp, dq);
       // abnocpdq = ((a ^ n) | (b ^ o)) | ((c ^ p) | (d ^ q)).  Reduce this to
       // a nonzero 32 bit value if a mismatch occurred.
       uint64x2_t abnocpdq = vreinterpretq_u64_u8(anbo | cpdq);


        


More information about the libc-commits mailing list