[llvm-commits] [llvm] r67435 - /llvm/trunk/lib/VMCore/Constants.cpp
Chris Lattner
sabre at nondot.org
Fri Mar 20 23:55:54 PDT 2009
Author: lattner
Date: Sat Mar 21 01:55:54 2009
New Revision: 67435
URL: http://llvm.org/viewvc/llvm-project?rev=67435&view=rev
Log:
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.
Modified:
llvm/trunk/lib/VMCore/Constants.cpp
Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=67435&r1=67434&r2=67435&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Sat Mar 21 01:55:54 2009
@@ -1996,6 +1996,11 @@
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);
}
More information about the llvm-commits
mailing list