diff options
author | Evandro Menezes <e.menezes@samsung.com> | 2019-09-30 20:53:23 +0000 |
---|---|---|
committer | Evandro Menezes <e.menezes@samsung.com> | 2019-09-30 20:53:23 +0000 |
commit | 22cb3d2e58f4f232e353678f750d5659c4673520 (patch) | |
tree | f1ec8d8fe3b6042f0faa21d5a906bf32381035e5 /llvm/lib/Analysis/ConstantFolding.cpp | |
parent | 110b1138baf4b0736cd65c5fa4b3b697c318a6da (diff) | |
download | bcm5719-llvm-22cb3d2e58f4f232e353678f750d5659c4673520.tar.gz bcm5719-llvm-22cb3d2e58f4f232e353678f750d5659c4673520.zip |
[ConstantFolding] Fold constant calls to log2()
Somehow, folding calls to `log2()` with a constant was missing.
Differential revision: https://reviews.llvm.org/D67300
llvm-svn: 373262
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index f8ea8cfc354..8dbcf7034fd 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -1508,6 +1508,7 @@ bool llvm::canConstantFoldCallTo(const CallBase *Call, const Function *F) { Name == "fmod" || Name == "fmodf"; case 'l': return Name == "log" || Name == "logf" || + Name == "log2" || Name == "log2f" || Name == "log10" || Name == "log10f"; case 'n': return Name == "nearbyint" || Name == "nearbyintf"; @@ -1890,6 +1891,14 @@ static Constant *ConstantFoldScalarCall1(StringRef Name, if (V > 0.0 && TLI->has(Func)) return ConstantFoldFP(log, V, Ty); break; + case LibFunc_log2: + case LibFunc_log2f: + case LibFunc_log2_finite: + case LibFunc_log2f_finite: + if (V > 0.0 && TLI->has(Func)) + // TODO: What about hosts that lack a C99 library? + return ConstantFoldFP(Log2, V, Ty); + break; case LibFunc_log10: case LibFunc_log10f: case LibFunc_log10_finite: |