diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -599,12 +599,6 @@ BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); - /// Check whether it is valid to call getCastOpcode for these types. - static bool isCastable( - Type *SrcTy, ///< The Type from which the value should be cast. - Type *DestTy ///< The Type to which the value should be cast. - ); - /// Check whether a bitcast between these types is valid static bool isBitCastable( Type *SrcTy, ///< The Type from which the value should be cast. diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -3142,64 +3142,6 @@ return Create(opcode, C, Ty, Name, InsertAtEnd); } -// Check whether it is valid to call getCastOpcode for these types. -// This routine must be kept in sync with getCastOpcode. -bool CastInst::isCastable(Type *SrcTy, Type *DestTy) { - if (!SrcTy->isFirstClassType() || !DestTy->isFirstClassType()) - return false; - - if (SrcTy == DestTy) - return true; - - if (VectorType *SrcVecTy = dyn_cast(SrcTy)) - if (VectorType *DestVecTy = dyn_cast(DestTy)) - if (cast(SrcVecTy)->getNumElements() == - cast(DestVecTy)->getNumElements()) { - // An element by element cast. Valid if casting the elements is valid. - SrcTy = SrcVecTy->getElementType(); - DestTy = DestVecTy->getElementType(); - } - - // Get the bit sizes, we'll need these - TypeSize SrcBits = SrcTy->getPrimitiveSizeInBits(); // 0 for ptr - TypeSize DestBits = DestTy->getPrimitiveSizeInBits(); // 0 for ptr - - // Run through the possibilities ... - if (DestTy->isIntegerTy()) { // Casting to integral - if (SrcTy->isIntegerTy()) // Casting from integral - return true; - if (SrcTy->isFloatingPointTy()) // Casting from floating pt - return true; - if (SrcTy->isVectorTy()) // Casting from vector - return DestBits == SrcBits; - // Casting from something else - return SrcTy->isPointerTy(); - } - if (DestTy->isFloatingPointTy()) { // Casting to floating pt - if (SrcTy->isIntegerTy()) // Casting from integral - return true; - if (SrcTy->isFloatingPointTy()) // Casting from floating pt - return true; - if (SrcTy->isVectorTy()) // Casting from vector - return DestBits == SrcBits; - // Casting from something else - return false; - } - if (DestTy->isVectorTy()) // Casting to vector - return DestBits == SrcBits; - if (DestTy->isPointerTy()) { // Casting to pointer - if (SrcTy->isPointerTy()) // Casting from pointer - return true; - return SrcTy->isIntegerTy(); // Casting from integral - } - if (DestTy->isX86_MMXTy()) { - if (SrcTy->isVectorTy()) - return DestBits == SrcBits; // 64-bit vector to MMX - return false; - } // Casting to something else - return false; -} - bool CastInst::isBitCastable(Type *SrcTy, Type *DestTy) { if (!SrcTy->isFirstClassType() || !DestTy->isFirstClassType()) return false; @@ -3261,7 +3203,6 @@ // castIsValid( getCastOpcode(Val, Ty), Val, Ty) // should not assert in castIsValid. In other words, this produces a "correct" // casting opcode for the arguments passed to it. -// This routine must be kept in sync with isCastable. Instruction::CastOps CastInst::getCastOpcode( const Value *Src, bool SrcIsSigned, Type *DestTy, bool DestIsSigned) { diff --git a/llvm/unittests/IR/InstructionsTest.cpp b/llvm/unittests/IR/InstructionsTest.cpp --- a/llvm/unittests/IR/InstructionsTest.cpp +++ b/llvm/unittests/IR/InstructionsTest.cpp @@ -229,11 +229,6 @@ const Constant *v2ptr32 = Constant::getNullValue(V2Int32PtrTy); - EXPECT_TRUE(CastInst::isCastable(V8x8Ty, X86MMXTy)); - EXPECT_TRUE(CastInst::isCastable(X86MMXTy, V8x8Ty)); - EXPECT_FALSE(CastInst::isCastable(Int64Ty, X86MMXTy)); - EXPECT_TRUE(CastInst::isCastable(V8x64Ty, V8x8Ty)); - EXPECT_TRUE(CastInst::isCastable(V8x8Ty, V8x64Ty)); EXPECT_EQ(CastInst::Trunc, CastInst::getCastOpcode(c64, true, V8x8Ty, true)); EXPECT_EQ(CastInst::SExt, CastInst::getCastOpcode(c8, true, V8x64Ty, true)); @@ -249,7 +244,6 @@ EXPECT_FALSE(CastInst::isBitCastable(V2Int32PtrTy, V2Int32PtrAS1Ty)); EXPECT_FALSE(CastInst::isBitCastable(V2Int32PtrAS1Ty, V2Int32PtrTy)); EXPECT_TRUE(CastInst::isBitCastable(V2Int32PtrAS1Ty, V2Int64PtrAS1Ty)); - EXPECT_TRUE(CastInst::isCastable(V2Int32PtrAS1Ty, V2Int32PtrTy)); EXPECT_EQ(CastInst::AddrSpaceCast, CastInst::getCastOpcode(v2ptr32, true, V2Int32PtrAS1Ty, true));