From fdd87907185162d3ffec237c426530d63c23bcca Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 5 Oct 2009 05:54:46 +0000 Subject: strength reduce a ton of type equality tests to check the typeid (Through the new predicates I added) instead of going through a context and doing a pointer comparison. Besides being cheaper, this allows a smart compiler to turn the if sequence into a switch. llvm-svn: 83297 --- llvm/lib/CodeGen/ELFWriter.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'llvm/lib/CodeGen/ELFWriter.cpp') diff --git a/llvm/lib/CodeGen/ELFWriter.cpp b/llvm/lib/CodeGen/ELFWriter.cpp index 55a2f700643..3e1ee11b216 100644 --- a/llvm/lib/CodeGen/ELFWriter.cpp +++ b/llvm/lib/CodeGen/ELFWriter.cpp @@ -457,16 +457,15 @@ void ELFWriter::EmitGlobalConstant(const Constant *CV, ELFSection &GblS) { return; } else if (const ConstantFP *CFP = dyn_cast(CV)) { APInt Val = CFP->getValueAPF().bitcastToAPInt(); - if (CFP->getType() == Type::getDoubleTy(CV->getContext())) + if (CFP->getType()->isDoubleTy()) GblS.emitWord64(Val.getZExtValue()); - else if (CFP->getType() == Type::getFloatTy(CV->getContext())) + else if (CFP->getType()->isFloatTy()) GblS.emitWord32(Val.getZExtValue()); - else if (CFP->getType() == Type::getX86_FP80Ty(CV->getContext())) { - unsigned PadSize = - TD->getTypeAllocSize(Type::getX86_FP80Ty(CV->getContext()))- - TD->getTypeStoreSize(Type::getX86_FP80Ty(CV->getContext())); + else if (CFP->getType()->isX86_FP80Ty()) { + unsigned PadSize = TD->getTypeAllocSize(CFP->getType())- + TD->getTypeStoreSize(CFP->getType()); GblS.emitWordFP80(Val.getRawData(), PadSize); - } else if (CFP->getType() == Type::getPPC_FP128Ty(CV->getContext())) + } else if (CFP->getType()->isPPC_FP128Ty()) llvm_unreachable("PPC_FP128Ty global emission not implemented"); return; } else if (const ConstantInt *CI = dyn_cast(CV)) { -- cgit v1.2.3