diff options
author | Chris Lattner <sabre@nondot.org> | 2004-06-11 06:16:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-06-11 06:16:23 +0000 |
commit | cf11035a6f9973d68d8eaf837d71dcf272d36b79 (patch) | |
tree | 8918d0518a4fcd2af8deac751e9929a8f574e60c /lib/Transforms/Utils/Local.cpp | |
parent | 7ba02f11157456c8ad6a43755f3b0754e99794d7 (diff) |
Constant fold the isnan intrinsic
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14150 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/Local.cpp')
-rw-r--r-- | lib/Transforms/Utils/Local.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index 256ddfdbcc..9d3338ffb7 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -15,6 +15,7 @@ #include "llvm/Transforms/Utils/Local.h" #include "llvm/Constants.h" #include "llvm/Instructions.h" +#include "llvm/Intrinsics.h" #include <cerrno> #include <cmath> using namespace llvm; @@ -234,6 +235,12 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB) { /// the specified function. bool llvm::canConstantFoldCallTo(Function *F) { const std::string &Name = F->getName(); + + switch (F->getIntrinsicID()) { + case Intrinsic::isnan: return true; + default: break; + } + return Name == "sin" || Name == "cos" || Name == "tan" || Name == "sqrt" || Name == "log" || Name == "log10" || Name == "exp" || Name == "pow" || Name == "acos" || Name == "asin" || Name == "atan" || Name == "fmod"; @@ -258,7 +265,9 @@ Constant *llvm::ConstantFoldCall(Function *F, if (Operands.size() == 1) { if (ConstantFP *Op = dyn_cast<ConstantFP>(Operands[0])) { double V = Op->getValue(); - if (Name == "sin") + if (Name == "llvm.isnan") + return ConstantBool::get(isnan(V)); + else if (Name == "sin") return ConstantFP::get(Ty, sin(V)); else if (Name == "cos") return ConstantFP::get(Ty, cos(V)); |