[compiler-rt] r250359 - builtins: __builtin_clzll for x86 on MSVC
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 14 19:46:37 PDT 2015
Author: compnerd
Date: Wed Oct 14 21:46:37 2015
New Revision: 250359
URL: http://llvm.org/viewvc/llvm-project?rev=250359&view=rev
Log:
builtins: __builtin_clzll for x86 on MSVC
Add an implementation for __builtin_clzll on MSVC even when _BitScanForward4 is
unavailable.
Patch by Tee Hao Wei!
Modified:
compiler-rt/trunk/lib/builtins/int_lib.h
Modified: compiler-rt/trunk/lib/builtins/int_lib.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/int_lib.h?rev=250359&r1=250358&r2=250359&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/int_lib.h (original)
+++ compiler-rt/trunk/lib/builtins/int_lib.h Wed Oct 14 21:46:37 2015
@@ -115,9 +115,19 @@ uint32_t __inline __builtin_clzll(uint64
return 63 - leading_zero;
return 64;
}
+#else
+uint32_t __inline __builtin_clzll(uint64_t value) {
+ if (value == 0)
+ return 64;
+ uint32_t msh = (uint32_t)(value >> 32);
+ uint32_t lsh = (uint32_t)(value & 0xFFFFFFFF);
+ if (msh != 0)
+ return __builtin_clz(msh);
+ return 32 + __builtin_clz(lsh);
+}
+#endif
#define __builtin_clzl __builtin_clzll
-#endif
-#endif
+#endif // defined(_MSC_VER) && !defined(__clang__)
#endif /* INT_LIB_H */
More information about the llvm-commits
mailing list