summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ConstantFolding.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-01-16 21:12:35 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-01-16 21:12:35 +0000
commitb4f9a6f110ff455eaa3538275dcdbac0553031d4 (patch)
tree5c5b78085c246bceae041a795428b7aa0718b0fd /llvm/lib/Analysis/ConstantFolding.cpp
parent84c00ea718b269d245dbf8921061537a25f3ba9e (diff)
downloadbcm5719-llvm-b4f9a6f110ff455eaa3538275dcdbac0553031d4.tar.gz
bcm5719-llvm-b4f9a6f110ff455eaa3538275dcdbac0553031d4.zip
For PR411:
This patch is an incremental step towards supporting a flat symbol table. It de-overloads the intrinsic functions by providing type-specific intrinsics and arranging for automatically upgrading from the old overloaded name to the new non-overloaded name. Specifically: llvm.isunordered -> llvm.isunordered.f32, llvm.isunordered.f64 llvm.sqrt -> llvm.sqrt.f32, llvm.sqrt.f64 llvm.ctpop -> llvm.ctpop.i8, llvm.ctpop.i16, llvm.ctpop.i32, llvm.ctpop.i64 llvm.ctlz -> llvm.ctlz.i8, llvm.ctlz.i16, llvm.ctlz.i32, llvm.ctlz.i64 llvm.cttz -> llvm.cttz.i8, llvm.cttz.i16, llvm.cttz.i32, llvm.cttz.i64 New code should not use the overloaded intrinsic names. Warnings will be emitted if they are used. llvm-svn: 25366
Diffstat (limited to 'llvm/lib/Analysis/ConstantFolding.cpp')
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 915a7cb734f..3321115c53e 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -35,15 +35,26 @@ llvm::canConstantFoldCallTo(Function *F) {
const std::string &Name = F->getName();
switch (F->getIntrinsicID()) {
- case Intrinsic::isunordered:
- case Intrinsic::sqrt:
+ case Intrinsic::isunordered_f32:
+ case Intrinsic::isunordered_f64:
+ case Intrinsic::sqrt_f32:
+ case Intrinsic::sqrt_f64:
case Intrinsic::bswap_i16:
case Intrinsic::bswap_i32:
case Intrinsic::bswap_i64:
// FIXME: these should be constant folded as well
- //case Intrinsic::ctpop:
- //case Intrinsic::ctlz:
- //case Intrinsic::cttz:
+ //case Intrinsic::ctpop_i8:
+ //case Intrinsic::ctpop_i16:
+ //case Intrinsic::ctpop_i32:
+ //case Intrinsic::ctpop_i64:
+ //case Intrinsic::ctlz_i8:
+ //case Intrinsic::ctlz_i16:
+ //case Intrinsic::ctlz_i32:
+ //case Intrinsic::ctlz_i64:
+ //case Intrinsic::cttz_i8:
+ //case Intrinsic::cttz_i16:
+ //case Intrinsic::cttz_i32:
+ //case Intrinsic::cttz_i64:
return true;
default: break;
}
@@ -125,7 +136,7 @@ llvm::ConstantFoldCall(Function *F, const std::vector<Constant*> &Operands) {
return ConstantFP::get(Ty, log(V));
else if (Name == "log10" && V > 0)
return ConstantFoldFP(log10, V, Ty);
- else if (Name == "llvm.sqrt") {
+ else if (Name == "llvm.sqrt.f32" || Name == "llvm.sqrt.f64") {
if (V >= -0.0)
return ConstantFP::get(Ty, sqrt(V));
else // Undefined
@@ -164,7 +175,7 @@ llvm::ConstantFoldCall(Function *F, const std::vector<Constant*> &Operands) {
if (ConstantFP *Op2 = dyn_cast<ConstantFP>(Operands[1])) {
double Op2V = Op2->getValue();
- if (Name == "llvm.isunordered")
+ if (Name == "llvm.isunordered.f32" || Name == "llvm.isunordered.f64")
return ConstantBool::get(IsNAN(Op1V) || IsNAN(Op2V));
else
if (Name == "pow") {
OpenPOWER on IntegriCloud