diff options
author | Chris Lattner <sabre@nondot.org> | 2005-09-28 01:34:32 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-09-28 01:34:32 +0000 |
commit | 32643d8e057b8ef58b1d8c915e458926f3593bdf (patch) | |
tree | 2b6717c17fc72372b3f4572e8c6127cc479e800a | |
parent | 5b3c70263b27dcab5e588c7de40a67be0738be6a (diff) | |
download | external_llvm-32643d8e057b8ef58b1d8c915e458926f3593bdf.zip external_llvm-32643d8e057b8ef58b1d8c915e458926f3593bdf.tar.gz external_llvm-32643d8e057b8ef58b1d8c915e458926f3593bdf.tar.bz2 |
Constant fold llvm.sqrt
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23487 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Utils/Local.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index b1dd583..a9cfcc0 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -240,7 +240,9 @@ bool llvm::canConstantFoldCallTo(Function *F) { const std::string &Name = F->getName(); switch (F->getIntrinsicID()) { - case Intrinsic::isunordered: return true; + case Intrinsic::isunordered: + case Intrinsic::sqrt: + return true; default: break; } @@ -321,6 +323,12 @@ Constant *llvm::ConstantFoldCall(Function *F, return ConstantFP::get(Ty, log(V)); else if (Name == "log10" && V > 0) return ConstantFoldFP(log10, V, Ty); + else if (Name == "llvm.sqrt") { + if (V >= -0.0) + return ConstantFP::get(Ty, sqrt(V)); + else // Undefined + return ConstantFP::get(Ty, 0.0); + } break; case 's': if (Name == "sin") |