[llvm-commits] CVS: llvm/lib/Analysis/ConstantFolding.cpp
Chris Lattner
sabre at nondot.org
Sun Jan 14 22:27:52 PST 2007
Changes in directory llvm/lib/Analysis:
ConstantFolding.cpp updated: 1.9 -> 1.10
---
Log message:
Constant fold llvm.powi.*. This speeds up tramp3d--v4 by 9.5%
---
Diffs of the changes: (+12 -1)
ConstantFolding.cpp | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletion(-)
Index: llvm/lib/Analysis/ConstantFolding.cpp
diff -u llvm/lib/Analysis/ConstantFolding.cpp:1.9 llvm/lib/Analysis/ConstantFolding.cpp:1.10
--- llvm/lib/Analysis/ConstantFolding.cpp:1.9 Sun Jan 7 02:19:47 2007
+++ llvm/lib/Analysis/ConstantFolding.cpp Mon Jan 15 00:27:37 2007
@@ -40,6 +40,8 @@
case Intrinsic::bswap_i16:
case Intrinsic::bswap_i32:
case Intrinsic::bswap_i64:
+ case Intrinsic::powi_f32:
+ case Intrinsic::powi_f64:
// FIXME: these should be constant folded as well
//case Intrinsic::ctpop_i8:
//case Intrinsic::ctpop_i16:
@@ -186,8 +188,17 @@
double V = fmod(Op1V, Op2V);
if (errno == 0)
return ConstantFP::get(Ty, V);
- } else if (Name == "atan2")
+ } else if (Name == "atan2") {
return ConstantFP::get(Ty, atan2(Op1V,Op2V));
+ }
+ } else if (ConstantInt *Op2C = dyn_cast<ConstantInt>(Operands[1])) {
+ if (Name == "llvm.powi.f32") {
+ return ConstantFP::get(Ty, std::pow((float)Op1V,
+ (int)Op2C->getZExtValue()));
+ } else if (Name == "llvm.powi.f64") {
+ return ConstantFP::get(Ty, std::pow((double)Op1V,
+ (int)Op2C->getZExtValue()));
+ }
}
}
}
More information about the llvm-commits
mailing list