Support alignment queries for degenerate (length 1) vectors.
authorChristopher Lamb <christopher.lamb@gmail.com>
Sun, 22 Apr 2007 21:54:13 +0000 (21:54 +0000)
committerChristopher Lamb <christopher.lamb@gmail.com>
Sun, 22 Apr 2007 21:54:13 +0000 (21:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36352 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/TargetData.cpp

index 10ee707aea4df205779d6348f9da880ff623e57b..2cbb903b96308acbfaed41ed67b5819356c3bdd5 100644 (file)
@@ -493,9 +493,15 @@ unsigned char TargetData::getAlignment(const Type *Ty, bool abi_or_pref) const {
   case Type::DoubleTyID:
     AlignType = FLOAT_ALIGN;
     break;
-  case Type::VectorTyID:
-    AlignType = VECTOR_ALIGN;
+  case Type::VectorTyID: {
+    const VectorType *VTy = cast<VectorType>(Ty);
+    // Degenerate vectors are assumed to be scalar-ized
+    if (VTy->getNumElements() == 1)
+      return getAlignment(VTy->getElementType(), abi_or_pref);
+    else
+      AlignType = VECTOR_ALIGN;
     break;
+  }
   default:
     assert(0 && "Bad type for getAlignment!!!");
     break;