[PATCH] D131656: [Support] Remove Log2 workaround for Android API level < 18
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 11 00:34:15 PDT 2022
MaskRay created this revision.
MaskRay added reviewers: pirama, srhines.
Herald added subscribers: danielkiss, StephenFan, hiraditya.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
I wonder whether the function added by D9467 <https://reviews.llvm.org/D9467> is still needed considering
that API level < 18 seems very old now.
::log2 has been used in many other places now.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D131656
Files:
llvm/include/llvm/Support/MathExtras.h
llvm/lib/Analysis/ConstantFolding.cpp
Index: llvm/lib/Analysis/ConstantFolding.cpp
===================================================================
--- llvm/lib/Analysis/ConstantFolding.cpp
+++ llvm/lib/Analysis/ConstantFolding.cpp
@@ -2150,7 +2150,7 @@
return ConstantFoldFP(log, APF, Ty);
case Intrinsic::log2:
// TODO: What about hosts that lack a C99 library?
- return ConstantFoldFP(Log2, APF, Ty);
+ return ConstantFoldFP(log2, APF, Ty);
case Intrinsic::log10:
// TODO: What about hosts that lack a C99 library?
return ConstantFoldFP(log10, APF, Ty);
@@ -2279,7 +2279,7 @@
case LibFunc_log2f_finite:
if (!APF.isNegative() && !APF.isZero() && TLI->has(Func))
// TODO: What about hosts that lack a C99 library?
- return ConstantFoldFP(Log2, APF, Ty);
+ return ConstantFoldFP(log2, APF, Ty);
break;
case LibFunc_log10:
case LibFunc_log10f:
Index: llvm/include/llvm/Support/MathExtras.h
===================================================================
--- llvm/include/llvm/Support/MathExtras.h
+++ llvm/include/llvm/Support/MathExtras.h
@@ -22,10 +22,6 @@
#include <limits>
#include <type_traits>
-#ifdef __ANDROID_NDK__
-#include <android/api-level.h>
-#endif
-
#ifdef _MSC_VER
// Declare these intrinsics manually rather including intrin.h. It's very
// expensive, and MathExtras.h is popular.
@@ -608,15 +604,6 @@
template <> constexpr inline size_t CTLog2<1>() { return 0; }
-/// Return the log base 2 of the specified value.
-inline double Log2(double Value) {
-#if defined(__ANDROID_API__) && __ANDROID_API__ < 18
- return __builtin_log(Value) / __builtin_log(2.0);
-#else
- return log2(Value);
-#endif
-}
-
/// Return the floor log base 2 of the specified value, -1 if the value is zero.
/// (32 bit edition.)
/// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131656.451755.patch
Type: text/x-patch
Size: 1898 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220811/b39c9c33/attachment.bin>
More information about the llvm-commits
mailing list