aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/IntrinsicLowering.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2007-10-02 17:43:59 +0000
committerDale Johannesen <dalej@apple.com>2007-10-02 17:43:59 +0000
commit9ab7fb3ba47442d521a5bed09a27a5e8e7a786ed (patch)
treeb23da219f3f8c1bb5cef7f93bb79892b765bfdf9 /lib/CodeGen/IntrinsicLowering.cpp
parentf09156837508435dc38c6827b552bcbddf6500c2 (diff)
Rewrite sqrt and powi to use anyfloat. By popular demand.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42537 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/IntrinsicLowering.cpp')
-rw-r--r--lib/CodeGen/IntrinsicLowering.cpp57
1 files changed, 28 insertions, 29 deletions
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp
index 0a2f0d6a51..cf47091a5c 100644
--- a/lib/CodeGen/IntrinsicLowering.cpp
+++ b/lib/CodeGen/IntrinsicLowering.cpp
@@ -99,14 +99,20 @@ void IntrinsicLowering::AddPrototypes(Module &M) {
PointerType::get(Type::Int8Ty), Type::Int32Ty,
TD.getIntPtrType(), (Type *)0);
break;
- case Intrinsic::sqrt_f32:
- case Intrinsic::sqrt_f64:
- if(I->arg_begin()->getType() == Type::FloatTy)
+ case Intrinsic::sqrt:
+ switch((int)I->arg_begin()->getType()->getTypeID()) {
+ case Type::FloatTyID:
EnsureFunctionExists(M, "sqrtf", I->arg_begin(), I->arg_end(),
Type::FloatTy);
- else
+ case Type::DoubleTyID:
EnsureFunctionExists(M, "sqrt", I->arg_begin(), I->arg_end(),
Type::DoubleTy);
+ case Type::X86_FP80TyID:
+ case Type::FP128TyID:
+ case Type::PPC_FP128TyID:
+ EnsureFunctionExists(M, "sqrtl", I->arg_begin(), I->arg_end(),
+ I->arg_begin()->getType());
+ }
break;
}
}
@@ -782,34 +788,27 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
MemsetFCache);
break;
}
- case Intrinsic::sqrt_f32: {
+ case Intrinsic::sqrt: {
static Constant *sqrtfFCache = 0;
- ReplaceCallWith("sqrtf", CI, CI->op_begin()+1, CI->op_end(),
- Type::FloatTy, sqrtfFCache);
- break;
- }
- case Intrinsic::sqrt_f64: {
static Constant *sqrtFCache = 0;
- ReplaceCallWith("sqrt", CI, CI->op_begin()+1, CI->op_end(),
+ static Constant *sqrtLDCache = 0;
+ switch (CI->getOperand(1)->getType()->getTypeID()) {
+ default: assert(0 && "Invalid type in sqrt"); abort();
+ case Type::FloatTyID:
+ ReplaceCallWith("sqrtf", CI, CI->op_begin()+1, CI->op_end(),
+ Type::FloatTy, sqrtfFCache);
+ break;
+ case Type::DoubleTyID:
+ ReplaceCallWith("sqrt", CI, CI->op_begin()+1, CI->op_end(),
Type::DoubleTy, sqrtFCache);
- break;
- }
- case Intrinsic::sqrt_f80: {
- static Constant *sqrtF80Cache = 0;
- ReplaceCallWith("sqrtl", CI, CI->op_begin()+1, CI->op_end(),
- Type::X86_FP80Ty, sqrtF80Cache);
- break;
- }
- case Intrinsic::sqrt_f128: {
- static Constant *sqrtF128Cache = 0;
- ReplaceCallWith("sqrtl", CI, CI->op_begin()+1, CI->op_end(),
- Type::FP128Ty, sqrtF128Cache);
- break;
- }
- case Intrinsic::sqrt_ppcf128: {
- static Constant *sqrtppcF128Cache = 0;
- ReplaceCallWith("sqrtl", CI, CI->op_begin()+1, CI->op_end(),
- Type::PPC_FP128Ty, sqrtppcF128Cache);
+ break;
+ case Type::X86_FP80TyID:
+ case Type::FP128TyID:
+ case Type::PPC_FP128TyID:
+ ReplaceCallWith("sqrtl", CI, CI->op_begin()+1, CI->op_end(),
+ CI->getOperand(1)->getType(), sqrtLDCache);
+ break;
+ }
break;
}
}