diff --git a/compiler-rt/lib/builtins/floattitf.c b/compiler-rt/lib/builtins/floattitf.c --- a/compiler-rt/lib/builtins/floattitf.c +++ b/compiler-rt/lib/builtins/floattitf.c @@ -26,6 +26,9 @@ // mmmm mmmm mmmm #if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(__clang__) && defined(__sparc__) +#pragma clang optimize off +#endif COMPILER_RT_ABI fp_t __floattitf(ti_int a) { if (a == 0) return 0.0; @@ -74,5 +77,8 @@ fb.u.low.all = (du_int)(a); return fb.f; } +#if defined(__clang__) && defined(__sparc__) +#pragma clang optimize on +#endif #endif diff --git a/compiler-rt/lib/builtins/floatuntitf.c b/compiler-rt/lib/builtins/floatuntitf.c --- a/compiler-rt/lib/builtins/floatuntitf.c +++ b/compiler-rt/lib/builtins/floatuntitf.c @@ -26,6 +26,9 @@ // mmmm mmmm mmmm #if defined(CRT_HAS_128BIT) && defined(CRT_LDBL_128BIT) +#if defined(__clang__) && defined(__sparc__) +#pragma clang optimize off +#endif COMPILER_RT_ABI fp_t __floatuntitf(tu_int a) { if (a == 0) return 0.0; @@ -71,5 +74,8 @@ fb.u.low.all = (du_int)(a); return fb.f; } +#if defined(__clang__) && defined(__sparc__) +#pragma clang optimize on +#endif #endif diff --git a/compiler-rt/lib/builtins/fp_extend.h b/compiler-rt/lib/builtins/fp_extend.h --- a/compiler-rt/lib/builtins/fp_extend.h +++ b/compiler-rt/lib/builtins/fp_extend.h @@ -83,6 +83,9 @@ return rep.i; } +#if defined(__clang__) && defined(__sparc__) +#pragma clang optimize off +#endif static __inline dst_t dstFromRep(dst_rep_t x) { const union { dst_t f; @@ -90,6 +93,9 @@ } rep = {.i = x}; return rep.f; } +#if defined(__clang__) && defined(__sparc__) +#pragma clang optimize on +#endif // End helper routines. Conversion implementation follows. #endif // FP_EXTEND_HEADER diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h --- a/compiler-rt/lib/builtins/fp_lib.h +++ b/compiler-rt/lib/builtins/fp_lib.h @@ -230,6 +230,10 @@ return rep.i; } +// Work around miscompilation on sparcv9 (Bug 47729). +#if defined(__clang__) && defined(__sparc__) +#pragma clang optimize off +#endif static __inline fp_t fromRep(rep_t x) { const union { fp_t f; @@ -237,6 +241,9 @@ } rep = {.i = x}; return rep.f; } +#if defined(__clang__) && defined(__sparc__) +#pragma clang optimize on +#endif static __inline int normalize(rep_t *significand) { const int shift = rep_clz(*significand) - rep_clz(implicitBit);