diff options
author | Nate Begeman <natebegeman@mac.com> | 2007-11-17 03:58:34 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2007-11-17 03:58:34 +0000 |
commit | 78246cae8f37740879b3b099b388f0595106db6b (patch) | |
tree | a2c805de94c3e8f5ffbbeae56cee332a2a5a5695 /lib/VMCore/Instructions.cpp | |
parent | 111a45a2a32784b55e14c9ceb2a37fd2f244d43c (diff) | |
download | external_llvm-78246cae8f37740879b3b099b388f0595106db6b.zip external_llvm-78246cae8f37740879b3b099b388f0595106db6b.tar.gz external_llvm-78246cae8f37740879b3b099b388f0595106db6b.tar.bz2 |
Add support for vectors to int <-> float casts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44204 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Instructions.cpp')
-rw-r--r-- | lib/VMCore/Instructions.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index ed553e9..6bee186 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -1912,12 +1912,24 @@ CastInst::castIsValid(Instruction::CastOps op, Value *S, const Type *DstTy) { return SrcTy->isFloatingPoint() && DstTy->isFloatingPoint() && SrcBitSize < DstBitSize; case Instruction::UIToFP: - return SrcTy->isInteger() && DstTy->isFloatingPoint(); case Instruction::SIToFP: + if (const VectorType *SVTy = dyn_cast<VectorType>(SrcTy)) { + if (const VectorType *DVTy = dyn_cast<VectorType>(DstTy)) { + return SVTy->getElementType()->isInteger() && + DVTy->getElementType()->isFloatingPoint() && + SVTy->getNumElements() == DVTy->getNumElements(); + } + } return SrcTy->isInteger() && DstTy->isFloatingPoint(); case Instruction::FPToUI: - return SrcTy->isFloatingPoint() && DstTy->isInteger(); case Instruction::FPToSI: + if (const VectorType *SVTy = dyn_cast<VectorType>(SrcTy)) { + if (const VectorType *DVTy = dyn_cast<VectorType>(DstTy)) { + return SVTy->getElementType()->isFloatingPoint() && + DVTy->getElementType()->isInteger() && + SVTy->getNumElements() == DVTy->getNumElements(); + } + } return SrcTy->isFloatingPoint() && DstTy->isInteger(); case Instruction::PtrToInt: return isa<PointerType>(SrcTy) && DstTy->isInteger(); |