diff options
author | Chris Lattner <sabre@nondot.org> | 2011-05-22 22:22:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2011-05-22 22:22:35 +0000 |
commit | 713d52364fedc7680dc2f5358fd2ed8f661136a8 (patch) | |
tree | d5106c9b2613c1611f1bc920da2046eeb773595c /llvm/lib/Analysis/ConstantFolding.cpp | |
parent | 3bdc7679ce7bf7c6a62b37ec431f3490df732c90 (diff) | |
download | bcm5719-llvm-713d52364fedc7680dc2f5358fd2ed8f661136a8.tar.gz bcm5719-llvm-713d52364fedc7680dc2f5358fd2ed8f661136a8.zip |
implement PR9315, constant folding exp2 in terms of pow (since hosts without
C99 runtimes don't have exp2).
llvm-svn: 131872
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 5de2b04e80d..08a6065b31a 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -1085,7 +1085,7 @@ llvm::canConstantFoldCallTo(const Function *F) { case 'c': return Name == "cos" || Name == "ceil" || Name == "cosf" || Name == "cosh"; case 'e': - return Name == "exp"; + return Name == "exp" || Name == "exp2"; case 'f': return Name == "fabs" || Name == "fmod" || Name == "floor"; case 'l': @@ -1221,6 +1221,12 @@ llvm::ConstantFoldCall(Function *F, case 'e': if (Name == "exp") return ConstantFoldFP(exp, V, Ty); + + if (Name == "exp2") { + // Constant fold exp2(x) as pow(2,x) in case the host doesn't have a + // C99 library. + return ConstantFoldBinaryFP(pow, 2.0, V, Ty); + } break; case 'f': if (Name == "fabs") |