[PATCH] D43146: [builtins] Fix c?zdi2 on sparc64/Linux and ignore riscv32
Kristina Brooks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 18 11:58:21 PDT 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL342504: [builtins] Fix c?zdi2 on sparc64/Linux and ignore riscv32 (authored by kristina, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D43146
Files:
compiler-rt/trunk/lib/builtins/clzdi2.c
compiler-rt/trunk/lib/builtins/ctzdi2.c
Index: compiler-rt/trunk/lib/builtins/ctzdi2.c
===================================================================
--- compiler-rt/trunk/lib/builtins/ctzdi2.c
+++ compiler-rt/trunk/lib/builtins/ctzdi2.c
@@ -16,8 +16,13 @@
/* Returns: the number of trailing 0-bits */
-#if !defined(__clang__) && (defined(__sparc64__) || defined(__mips64) || defined(__riscv__))
-/* gcc resolves __builtin_ctz -> __ctzdi2 leading to infinite recursion */
+#if !defined(__clang__) && \
+ ((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_ctz to __ctzdi2 rather than
+ * __ctzsi2, leading to infinite recursion. */
#define __builtin_ctz(a) __ctzsi2(a)
extern si_int __ctzsi2(si_int);
#endif
Index: compiler-rt/trunk/lib/builtins/clzdi2.c
===================================================================
--- compiler-rt/trunk/lib/builtins/clzdi2.c
+++ compiler-rt/trunk/lib/builtins/clzdi2.c
@@ -16,8 +16,13 @@
/* Returns: the number of leading 0-bits */
-#if !defined(__clang__) && (defined(__sparc64__) || defined(__mips64) || defined(__riscv__))
-/* gcc resolves __builtin_clz -> __clzdi2 leading to infinite recursion */
+#if !defined(__clang__) && \
+ ((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. */
#define __builtin_clz(a) __clzsi2(a)
extern si_int __clzsi2(si_int);
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43146.166014.patch
Type: text/x-patch
Size: 2038 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180918/d8a66ebb/attachment-0001.bin>
More information about the llvm-commits
mailing list