diff options
author | Chris Lattner <sabre@nondot.org> | 2005-04-30 04:07:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-04-30 04:07:50 +0000 |
commit | 30fe4ac2fba16f770cc7f3ee12b97e7c5a8e79fd (patch) | |
tree | c114d2f8555af7419627ca7c8c935d6f62ebd402 | |
parent | 7100fcde6cc7c659046a300731f6e7a880a9d61c (diff) | |
download | bcm5719-llvm-30fe4ac2fba16f770cc7f3ee12b97e7c5a8e79fd.tar.gz bcm5719-llvm-30fe4ac2fba16f770cc7f3ee12b97e7c5a8e79fd.zip |
Lower llvm.sqrt -> fsqrt/sqrt
llvm-svn: 21629
-rw-r--r-- | llvm/lib/CodeGen/IntrinsicLowering.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/IntrinsicLowering.cpp b/llvm/lib/CodeGen/IntrinsicLowering.cpp index db3c10e7ead..712ec0482c4 100644 --- a/llvm/lib/CodeGen/IntrinsicLowering.cpp +++ b/llvm/lib/CodeGen/IntrinsicLowering.cpp @@ -110,8 +110,13 @@ void DefaultIntrinsicLowering::AddPrototypes(Module &M) { case Intrinsic::isunordered: EnsureFunctionExists(M, "isunordered", I->arg_begin(), I->arg_end(), Type::BoolTy); break; + case Intrinsic::sqrt: + if(I->abegin()->getType() == Type::FloatTy) + EnsureFunctionExists(M, "sqrtf", I->arg_begin(), I->arg_end(), Type::FloatTy); + else + EnsureFunctionExists(M, "sqrt", I->arg_begin(), I->arg_end(), Type::DoubleTy); + break; } - } void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { @@ -219,6 +224,17 @@ void DefaultIntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { "isunordered", CI)); break; } + case Intrinsic::sqrt: { + static Function *sqrtFCache = 0; + static Function *sqrtfFCache = 0; + if(CI->getType() == Type::FloatTy) + ReplaceCallWith("sqrtf", CI, CI->op_begin()+1, CI->op_end(), + Type::FloatTy, sqrtfFCache); + else + ReplaceCallWith("sqrt", CI, CI->op_begin()+1, CI->op_end(), + Type::DoubleTy, sqrtFCache); + break; + } } assert(CI->use_empty() && |