summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2011-04-01 03:34:54 +0000
committerDuncan Sands <baldrick@free.fr>2011-04-01 03:34:54 +0000
commit607946533d4eb781713b363605c4a241503dbe0e (patch)
treede13d8bf26bcf858154d4ef7bbc09194eec732f0 /lib
parent234823297e0fc0babddd2ab84054bf68f64a54d1 (diff)
downloadllvm-607946533d4eb781713b363605c4a241503dbe0e.tar.gz
llvm-607946533d4eb781713b363605c4a241503dbe0e.tar.bz2
llvm-607946533d4eb781713b363605c4a241503dbe0e.tar.xz
While testing dragonegg I noticed that isCastable and getCastOpcode
had gotten out of sync: isCastable didn't think it was possible to cast the x86_mmx type to anything, while it did think it possible to cast an i64 to x86_mmx. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@128705 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/VMCore/Instructions.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index d1290281cb..622edde512 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -2297,8 +2297,12 @@ bool CastInst::isCastable(const Type *SrcTy, const Type *DestTy) {
if (const VectorType *SrcPTy = dyn_cast<VectorType>(SrcTy)) {
// Casting from vector
return DestPTy->getBitWidth() == SrcPTy->getBitWidth();
- } else { // Casting from something else
- return DestPTy->getBitWidth() == SrcBits;
+ } else if (DestPTy->getBitWidth() == SrcBits) {
+ return true; // float/int -> vector
+ } else if (SrcTy->isX86_MMXTy()) {
+ return DestPTy->getBitWidth() == 64; // MMX to 64-bit vector
+ } else {
+ return false;
}
} else if (DestTy->isPointerTy()) { // Casting to pointer
if (SrcTy->isPointerTy()) { // Casting from pointer
@@ -2308,8 +2312,12 @@ bool CastInst::isCastable(const Type *SrcTy, const Type *DestTy) {
} else { // Casting from something else
return false;
}
- } else if (DestTy->isX86_MMXTy()) {
- return SrcBits == 64;
+ } else if (DestTy->isX86_MMXTy()) {
+ if (const VectorType *SrcPTy = dyn_cast<VectorType>(SrcTy)) {
+ return SrcPTy->getBitWidth() == 64; // 64-bit vector to MMX
+ } else {
+ return false;
+ }
} else { // Casting to something else
return false;
}