[compiler-rt] [compiler-rt] Make sure __clzdi2 doesn't call itself recursively on sparc64 (PR #136737)
Sergei Barannikov via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 22 21:59:37 PDT 2025
================
@@ -14,12 +14,12 @@
// Returns: the number of leading 0-bits
-#if !defined(__clang__) && \
- ((defined(__sparc__) && defined(__arch64__)) || defined(__mips64) || \
+#if ((defined(__sparc__) && defined(__arch64__)) || defined(__mips64) || \
(defined(__riscv) && __SIZEOF_POINTER__ >= 8))
// On 64-bit architectures with neither a native clz instruction nor a native
-// ctz instruction, gcc resolves __builtin_clz to __clzdi2 rather than
-// __clzsi2, leading to infinite recursion.
+// ctz instruction, `__builtin_clz` resolves to `__clzdi2` rather than
+// __clzsi2 as libgcc does not ship with `__clzsi2`, leading to infinite
+// recursion.
----------------
s-barannikov wrote:
That's doesn't seem to be true on RISC-V/Mips (clang).
https://godbolt.org/z/z8Yd9dr5K
https://github.com/llvm/llvm-project/pull/136737
More information about the llvm-commits
mailing list