[libc-commits] [libc] cb88897 - [libc] Improve bcmp performance for aarch64

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Thu Nov 24 11:24:55 PST 2022


Author: Guillaume Chatelet
Date: 2022-11-24T19:24:44Z
New Revision: cb888971d233a53282c31f498b79b9d788a402d6

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

LOG: [libc] Improve bcmp performance for aarch64

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libc/src/string/memory_utils/bcmp_implementations.h b/libc/src/string/memory_utils/bcmp_implementations.h
index 2e18ee81aaf6f..7a7054b3376f9 100644
--- a/libc/src/string/memory_utils/bcmp_implementations.h
+++ b/libc/src/string/memory_utils/bcmp_implementations.h
@@ -116,7 +116,7 @@ inline_bcmp_x86_avx512bw_gt16(CPtr p1, CPtr p2, size_t count) {
 inline_bcmp_aarch64(CPtr p1, CPtr p2, size_t count) {
   if (likely(count <= 32)) {
     if (unlikely(count >= 16)) {
-      return generic::Bcmp<16>::head_tail(p1, p2, count);
+      return aarch64::Bcmp<16>::head_tail(p1, p2, count);
     }
     switch (count) {
     case 0:
@@ -147,15 +147,15 @@ inline_bcmp_aarch64(CPtr p1, CPtr p2, size_t count) {
   }
 
   if (count <= 64)
-    return generic::Bcmp<32>::head_tail(p1, p2, count);
+    return aarch64::Bcmp<32>::head_tail(p1, p2, count);
 
   // Aligned loop if > 256, otherwise normal loop
-  if (count > 256) {
-    if (auto value = generic::Bcmp<32>::block(p1, p2))
+  if (unlikely(count > 256)) {
+    if (auto value = aarch64::Bcmp<32>::block(p1, p2))
       return value;
     align_to_next_boundary<16, Arg::P1>(p1, p2, count);
   }
-  return generic::Bcmp<32>::loop_and_tail(p1, p2, count);
+  return aarch64::Bcmp<32>::loop_and_tail(p1, p2, count);
 }
 #endif // defined(LLVM_LIBC_ARCH_AARCH64)
 


        


More information about the libc-commits mailing list