diff options
| -rw-r--r-- | llvm/lib/VMCore/Constants.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp index ed1e04ad547..6c99a1ffe88 100644 --- a/llvm/lib/VMCore/Constants.cpp +++ b/llvm/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); } |

