[llvm-commits] [llvm] r103877 - in /llvm/trunk: include/llvm/Config/config.h.cmake lib/Support/APInt.cpp
Chris Lattner
sabre at nondot.org
Sat May 15 10:11:55 PDT 2010
Author: lattner
Date: Sat May 15 12:11:55 2010
New Revision: 103877
URL: http://llvm.org/viewvc/llvm-project?rev=103877&view=rev
Log:
improve portability to systems that don't have round, patch by
Evzen Muller!
Modified:
llvm/trunk/include/llvm/Config/config.h.cmake
llvm/trunk/lib/Support/APInt.cpp
Modified: llvm/trunk/include/llvm/Config/config.h.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=103877&r1=103876&r2=103877&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Config/config.h.cmake (original)
+++ llvm/trunk/include/llvm/Config/config.h.cmake Sat May 15 12:11:55 2010
@@ -312,6 +312,9 @@
/* Define to 1 if you have the `roundf' function. */
#undef HAVE_ROUNDF
+/* Define to 1 if you have the `round' function. */
+#cmakedefine HAVE_ROUND ${HAVE_ROUND}
+
/* Define to 1 if you have the `sbrk' function. */
#cmakedefine HAVE_SBRK ${HAVE_SBRK}
Modified: llvm/trunk/lib/Support/APInt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=103877&r1=103876&r2=103877&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Sat May 15 12:11:55 2010
@@ -1382,13 +1382,12 @@
// libc sqrt function which will probably use a hardware sqrt computation.
// This should be faster than the algorithm below.
if (magnitude < 52) {
-#if defined( _MSC_VER ) || defined(_MINIX)
- // Amazingly, VC++ and Minix don't have round().
+#if HAVE_ROUND
return APInt(BitWidth,
- uint64_t(::sqrt(double(isSingleWord()?VAL:pVal[0]))) + 0.5);
+ uint64_t(::round(::sqrt(double(isSingleWord()?VAL:pVal[0])))));
#else
return APInt(BitWidth,
- uint64_t(::round(::sqrt(double(isSingleWord()?VAL:pVal[0])))));
+ uint64_t(::sqrt(double(isSingleWord()?VAL:pVal[0]))) + 0.5);
#endif
}
More information about the llvm-commits
mailing list