[libc-commits] [libc] bdac972 - Fix load64_aligned (#71391)

via libc-commits libc-commits at lists.llvm.org
Mon Nov 6 05:59:30 PST 2023


Author: Guillaume Chatelet
Date: 2023-11-06T14:59:26+01:00
New Revision: bdac9720712aedae04ba96c53775d59e80aae69b

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

LOG: Fix load64_aligned (#71391)

Fix #64758 `load64_aligned` was missing a case for `alignment == 6`.

Added: 
    

Modified: 
    libc/src/string/memory_utils/generic/aligned_access.h

Removed: 
    


################################################################################
diff  --git a/libc/src/string/memory_utils/generic/aligned_access.h b/libc/src/string/memory_utils/generic/aligned_access.h
index 4238167e54d644d..65bc63f6cbe5571 100644
--- a/libc/src/string/memory_utils/generic/aligned_access.h
+++ b/libc/src/string/memory_utils/generic/aligned_access.h
@@ -28,7 +28,7 @@ namespace LIBC_NAMESPACE {
     return load32_aligned<uint32_t>(ptr, offset);
   else if (alignment == 2)
     return load32_aligned<uint16_t, uint16_t>(ptr, offset);
-  else
+  else // 1, 3
     return load32_aligned<uint8_t, uint16_t, uint8_t>(ptr, offset);
 }
 
@@ -38,9 +38,11 @@ namespace LIBC_NAMESPACE {
     return load64_aligned<uint64_t>(ptr, offset);
   else if (alignment == 4)
     return load64_aligned<uint32_t, uint32_t>(ptr, offset);
+  else if (alignment == 6)
+    return load64_aligned<uint16_t, uint32_t, uint16_t>(ptr, offset);
   else if (alignment == 2)
     return load64_aligned<uint16_t, uint16_t, uint16_t, uint16_t>(ptr, offset);
-  else
+  else // 1, 3, 5, 7
     return load64_aligned<uint8_t, uint16_t, uint16_t, uint16_t, uint8_t>(
         ptr, offset);
 }


        


More information about the libc-commits mailing list