add a fastpath to ConstantExpr::getBitCast to handle the case when an obviously

unneeded bitcast is requested.  This is common for frontends who just unconditionally
cast even if the target is often the right type already.  THis prevents going into
getFoldedCast which switches on the opcode and does a bunch of other stuff before
doing the same opzn.

llvm-svn: 67435
This commit is contained in:
Chris Lattner 2009-03-21 06:55:54 +00:00
parent 9e8120e067
commit cbeda87da1
1 changed files with 5 additions and 0 deletions

View File

@ -1996,6 +1996,11 @@ Constant *ConstantExpr::getBitCast(Constant *C, const Type *DstTy) {
unsigned DstBitSize = DstTy->getPrimitiveSizeInBits();
#endif
assert(SrcBitSize == DstBitSize && "BitCast requires types of same width");
// It is common to ask for a bitcast of a value to its own type, handle this
// speedily.
if (C->getType() == DstTy) return C;
return getFoldedCast(Instruction::BitCast, C, DstTy);
}