aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/VMCore/Constants.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index ed1e04ad54..6c99a1ffe8 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -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);
}