diff options
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: |