]> granicus.if.org Git - clang/commitdiff
When computing the alignof value for a vector type, ensure that
authorDan Gohman <gohman@apple.com>
Wed, 21 Apr 2010 23:32:43 +0000 (23:32 +0000)
committerDan Gohman <gohman@apple.com>
Wed, 21 Apr 2010 23:32:43 +0000 (23:32 +0000)
the alignment is a power of 2, even in the esoteric case of a
vector element which does not have a power-of-2 sizeof value.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102036 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp

index 96e2e75eaaaa5592f4498c5a306d2c763b2a9c37..7431a23cdd5a90d775cd356f03f85b11efc9b204 100644 (file)
@@ -515,7 +515,7 @@ ASTContext::getTypeInfo(const Type *T) {
     Align = Width;
     // If the alignment is not a power of 2, round up to the next power of 2.
     // This happens for non-power-of-2 length vectors.
-    if (VT->getNumElements() & (VT->getNumElements()-1)) {
+    if (Align & (Align-1)) {
       Align = llvm::NextPowerOf2(Align);
       Width = llvm::RoundUpToAlignment(Width, Align);
     }