[libc-commits] [libc] 7c9b8fa - [libc] Fix embedded version of bcmp / memcmp

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Fri Oct 14 06:10:26 PDT 2022


Author: Guillaume Chatelet
Date: 2022-10-14T13:09:53Z
New Revision: 7c9b8fa6d2d921569a1ebeb4816edb7b05a37cdd

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

LOG: [libc] Fix embedded version of bcmp / memcmp

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libc/src/string/memory_utils/bcmp_implementations.h b/libc/src/string/memory_utils/bcmp_implementations.h
index 2b744647e48b..9d9ad2bb9873 100644
--- a/libc/src/string/memory_utils/bcmp_implementations.h
+++ b/libc/src/string/memory_utils/bcmp_implementations.h
@@ -24,7 +24,7 @@ namespace __llvm_libc {
 inline_bcmp_embedded_tiny(CPtr p1, CPtr p2, size_t count) {
 #pragma nounroll
   for (size_t offset = 0; offset < count; ++offset)
-    if (auto value = generic::Bcmp<1>::block(p1, p2))
+    if (auto value = generic::Bcmp<1>::block(p1 + offset, p2 + offset))
       return value;
   return BcmpReturnType::ZERO();
 }

diff  --git a/libc/src/string/memory_utils/memcmp_implementations.h b/libc/src/string/memory_utils/memcmp_implementations.h
index faddebcb6622..af85afa696e9 100644
--- a/libc/src/string/memory_utils/memcmp_implementations.h
+++ b/libc/src/string/memory_utils/memcmp_implementations.h
@@ -24,7 +24,7 @@ namespace __llvm_libc {
 inline_memcmp_embedded_tiny(CPtr p1, CPtr p2, size_t count) {
 #pragma nounroll
   for (size_t offset = 0; offset < count; ++offset)
-    if (auto value = generic::Memcmp<1>::block(p1, p2))
+    if (auto value = generic::Memcmp<1>::block(p1 + offset, p2 + offset))
       return value;
   return MemcmpReturnType::ZERO();
 }


        


More information about the libc-commits mailing list