summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Instructions.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2007-11-17 03:58:34 +0000
committerNate Begeman <natebegeman@mac.com>2007-11-17 03:58:34 +0000
commitd4d45c268c407405aa3367eacd2412b43e144b87 (patch)
treec919e61bead63fe51b739b55006ca4e9b74b8a45 /llvm/lib/VMCore/Instructions.cpp
parentb6c40f3f1b580fc85f1ffb38fff40acc383bb6df (diff)
downloadbcm5719-llvm-d4d45c268c407405aa3367eacd2412b43e144b87.tar.gz
bcm5719-llvm-d4d45c268c407405aa3367eacd2412b43e144b87.zip
Add support for vectors to int <-> float casts.
llvm-svn: 44204
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r--llvm/lib/VMCore/Instructions.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index ed553e94ce8..6bee186e570 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/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();
OpenPOWER on IntegriCloud