[libc-commits] [libc] [libc] Fix BigInt shift on big-endian platforms (PR #196957)
Milad Fa via libc-commits
libc-commits at lists.llvm.org
Mon May 11 07:32:23 PDT 2026
https://github.com/miladfarca updated https://github.com/llvm/llvm-project/pull/196957
>From e29e10366fb34fc2dba08b149bc604a7f3048ad7 Mon Sep 17 00:00:00 2001
From: Milad Fa <mfarazma at ibm.com>
Date: Mon, 11 May 2026 14:05:01 +0000
Subject: [PATCH 1/2] Fix
---
libc/src/__support/big_int.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/src/__support/big_int.h b/libc/src/__support/big_int.h
index bb9cefd67b552..eef12a0fe657f 100644
--- a/libc/src/__support/big_int.h
+++ b/libc/src/__support/big_int.h
@@ -259,7 +259,7 @@ LIBC_INLINE constexpr cpp::array<word, N> shift(cpp::array<word, N> array,
constexpr size_t WORD_BITS = cpp::numeric_limits<word>::digits;
#ifdef LIBC_TYPES_HAS_INT128
constexpr size_t TOTAL_BITS = N * WORD_BITS;
- if constexpr (TOTAL_BITS == 128) {
+ if constexpr (TOTAL_BITS == 128 && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) {
using type = cpp::conditional_t<is_signed, __int128_t, __uint128_t>;
auto tmp = cpp::bit_cast<type>(array);
if constexpr (direction == LEFT)
>From 74658277aea18f97b8befc89beb55a5d2de448b3 Mon Sep 17 00:00:00 2001
From: Milad Fa <mfarazma at ibm.com>
Date: Mon, 11 May 2026 14:30:32 +0000
Subject: [PATCH 2/2] apply clang-format
---
libc/src/__support/big_int.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libc/src/__support/big_int.h b/libc/src/__support/big_int.h
index eef12a0fe657f..a6dcff27ca167 100644
--- a/libc/src/__support/big_int.h
+++ b/libc/src/__support/big_int.h
@@ -259,7 +259,8 @@ LIBC_INLINE constexpr cpp::array<word, N> shift(cpp::array<word, N> array,
constexpr size_t WORD_BITS = cpp::numeric_limits<word>::digits;
#ifdef LIBC_TYPES_HAS_INT128
constexpr size_t TOTAL_BITS = N * WORD_BITS;
- if constexpr (TOTAL_BITS == 128 && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) {
+ if constexpr (TOTAL_BITS == 128 &&
+ __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) {
using type = cpp::conditional_t<is_signed, __int128_t, __uint128_t>;
auto tmp = cpp::bit_cast<type>(array);
if constexpr (direction == LEFT)
More information about the libc-commits
mailing list