[llvm-commits] CVS: llvm/lib/Transforms/Utils/Local.cpp
Chris Lattner
lattner at cs.uiuc.edu
Fri Jun 11 01:22:14 PDT 2004
Changes in directory llvm/lib/Transforms/Utils:
Local.cpp updated: 1.24 -> 1.25
---
Log message:
Constant fold the isnan intrinsic
---
Diffs of the changes: (+10 -1)
Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.24 llvm/lib/Transforms/Utils/Local.cpp:1.25
--- llvm/lib/Transforms/Utils/Local.cpp:1.24 Thu May 27 02:25:00 2004
+++ llvm/lib/Transforms/Utils/Local.cpp Fri Jun 11 01:16:23 2004
@@ -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 @@
/// 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 @@
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));
More information about the llvm-commits
mailing list