[libc-commits] [libc] [libc] Suppress GCC loop optimization warning (PR #132458)
via libc-commits
libc-commits at lists.llvm.org
Fri Mar 21 12:27:00 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Joseph Huber (jhuber6)
<details>
<summary>Changes</summary>
Summary:
This appears to be a false positive on some versions of GCC.
---
Full diff: https://github.com/llvm/llvm-project/pull/132458.diff
1 Files Affected:
- (modified) libc/src/__support/big_int.h (+8-2)
``````````diff
diff --git a/libc/src/__support/big_int.h b/libc/src/__support/big_int.h
index 85db31d01399a..2a4a72e30b352 100644
--- a/libc/src/__support/big_int.h
+++ b/libc/src/__support/big_int.h
@@ -790,11 +790,17 @@ struct BigInt {
remainder[pos] = rem;
}
+ // GCC currently emits a false-positive warning on this for some compilers.
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Waggressive-loop-optimizations"
+
// Set the remaining lower bits of the remainder.
for (; pos > 0; --pos) {
remainder[pos - 1] = val[pos - 1];
}
+#pragma GCC diagnostic pop
+
*this = quotient;
return remainder;
}
@@ -851,8 +857,8 @@ struct BigInt {
result[i] = lhs[i] OP rhs[i]; \
return result; \
} \
- LIBC_INLINE friend constexpr BigInt operator OP##=(BigInt &lhs, \
- const BigInt &rhs) { \
+ LIBC_INLINE friend constexpr BigInt operator OP## = \
+ (BigInt & lhs, const BigInt &rhs) { \
for (size_t i = 0; i < WORD_COUNT; ++i) \
lhs[i] OP## = rhs[i]; \
return lhs; \
``````````
</details>
https://github.com/llvm/llvm-project/pull/132458
More information about the libc-commits
mailing list