[llvm-commits] [llvm-gcc-4.2] r42539 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Dale Johannesen
dalej at apple.com
Tue Oct 2 10:44:51 PDT 2007
Author: johannes
Date: Tue Oct 2 12:44:51 2007
New Revision: 42539
URL: http://llvm.org/viewvc/llvm-project?rev=42539&view=rev
Log:
Rewrite sqrt and powi to use anyfloat.
Modified:
llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=42539&r1=42538&r2=42539&view=diff
==============================================================================
--- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Tue Oct 2 12:44:51 2007
@@ -4052,17 +4052,10 @@
Value *TreeToLLVM::EmitBuiltinSQRT(tree exp) {
Value *Amt = Emit(TREE_VALUE(TREE_OPERAND(exp, 1)), 0);
Intrinsic::ID Id = Intrinsic::not_intrinsic;
+ const Type* Ty = Amt->getType();
- switch (Amt->getType()->getTypeID()) {
- default: assert(0 && "Unknown FP type!");
- case Type::FloatTyID: Id = Intrinsic::sqrt_f32; break;
- case Type::DoubleTyID: Id = Intrinsic::sqrt_f64; break;
- case Type::X86_FP80TyID: Id = Intrinsic::sqrt_f80; break;
- case Type::FP128TyID: Id = Intrinsic::sqrt_f128; break;
- case Type::PPC_FP128TyID: Id = Intrinsic::sqrt_ppcf128; break;
- }
-
- return Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Id),
+ return Builder.CreateCall(Intrinsic::getDeclaration(TheModule,
+ Intrinsic::sqrt, &Ty, 1),
Amt, "tmp");
}
@@ -4073,23 +4066,14 @@
Value *Val = Emit(TREE_VALUE(ArgList), 0);
Value *Pow = Emit(TREE_VALUE(TREE_CHAIN(ArgList)), 0);
+ const Type *Ty = Val->getType();
Pow = CastToSIntType(Pow, Type::Int32Ty);
- Intrinsic::ID Id = Intrinsic::not_intrinsic;
-
- switch (Val->getType()->getTypeID()) {
- default: assert(0 && "Unknown FP type!");
- case Type::FloatTyID: Id = Intrinsic::powi_f32; break;
- case Type::DoubleTyID: Id = Intrinsic::powi_f64; break;
- case Type::X86_FP80TyID: Id = Intrinsic::powi_f80; break;
- case Type::FP128TyID: Id = Intrinsic::powi_f128; break;
- case Type::PPC_FP128TyID: Id = Intrinsic::powi_ppcf128; break;
- }
-
SmallVector<Value *,2> Args;
Args.push_back(Val);
Args.push_back(Pow);
- return Builder.CreateCall(Intrinsic::getDeclaration(TheModule, Id),
+ return Builder.CreateCall(Intrinsic::getDeclaration(TheModule,
+ Intrinsic::powi, &Ty, 1),
Args.begin(), Args.end(), "tmp");
}
More information about the llvm-commits
mailing list