[llvm] r187813 - Use gnu style builtins in MathExtras.h with clang on Windows

Reid Kleckner reid at kleckner.net
Tue Aug 6 12:45:27 PDT 2013


Author: rnk
Date: Tue Aug  6 14:45:27 2013
New Revision: 187813

URL: http://llvm.org/viewvc/llvm-project?rev=187813&view=rev
Log:
Use gnu style builtins in MathExtras.h with clang on Windows

Clang does not provide BitScan* intrinsic implementations yet.

Modified:
    llvm/trunk/include/llvm/Support/MathExtras.h

Modified: llvm/trunk/include/llvm/Support/MathExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=187813&r1=187812&r2=187813&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MathExtras.h (original)
+++ llvm/trunk/include/llvm/Support/MathExtras.h Tue Aug  6 14:45:27 2013
@@ -80,7 +80,7 @@ inline std::size_t countTrailingZeros<ui
   if (ZB != ZB_Undefined && Val == 0)
     return 32;
 
-#if __GNUC__ >= 4
+#if __has_builtin(__builtin_ctz) || __GNUC_PREREQ(4, 0)
   return __builtin_ctz(Val);
 #elif _MSC_VER
   unsigned long Index;
@@ -95,7 +95,7 @@ inline std::size_t countTrailingZeros<ui
   if (ZB != ZB_Undefined && Val == 0)
     return 64;
 
-#if __GNUC__ >= 4
+#if __has_builtin(__builtin_ctzll) || __GNUC_PREREQ(4, 0)
   return __builtin_ctzll(Val);
 #elif _MSC_VER
   unsigned long Index;
@@ -146,7 +146,7 @@ inline std::size_t countLeadingZeros<uin
   if (ZB != ZB_Undefined && Val == 0)
     return 32;
 
-#if __GNUC__ >= 4
+#if __has_builtin(__builtin_clz) || __GNUC_PREREQ(4, 0)
   return __builtin_clz(Val);
 #elif _MSC_VER
   unsigned long Index;
@@ -161,7 +161,7 @@ inline std::size_t countLeadingZeros<uin
   if (ZB != ZB_Undefined && Val == 0)
     return 64;
 
-#if __GNUC__ >= 4
+#if __has_builtin(__builtin_clzll) || __GNUC_PREREQ(4, 0)
   return __builtin_clzll(Val);
 #elif _MSC_VER
   unsigned long Index;





More information about the llvm-commits mailing list