Index: lib/Transforms/Vectorize/LoadStoreVectorizer.cpp =================================================================== --- lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -40,9 +40,8 @@ namespace { -// TODO: Remove this -static const unsigned TargetBaseAlign = 4; - +// FIXME: Assuming stack alignment of 4 is always good enough +static const unsigned StackAdjustedAlignment = 4; typedef SmallVector InstrList; typedef MapVector InstrListMap; @@ -798,8 +797,8 @@ // so we can cheat and change it! Value *V = GetUnderlyingObject(S0->getPointerOperand(), DL); if (AllocaInst *AI = dyn_cast_or_null(V)) { - AI->setAlignment(TargetBaseAlign); - Alignment = TargetBaseAlign; + AI->setAlignment(StackAdjustedAlignment); + Alignment = StackAdjustedAlignment; } else { return false; } @@ -948,8 +947,8 @@ // so we can cheat and change it! Value *V = GetUnderlyingObject(L0->getPointerOperand(), DL); if (AllocaInst *AI = dyn_cast_or_null(V)) { - AI->setAlignment(TargetBaseAlign); - Alignment = TargetBaseAlign; + AI->setAlignment(StackAdjustedAlignment); + Alignment = StackAdjustedAlignment; } else { return false; } @@ -1029,10 +1028,10 @@ bool Vectorizer::accessIsMisaligned(unsigned SzInBytes, unsigned AddressSpace, unsigned Alignment) { + if (Alignment % SzInBytes == 0) + return false; bool Fast = false; bool Allows = TTI.allowsMisalignedMemoryAccesses(SzInBytes * 8, AddressSpace, Alignment, &Fast); - // TODO: Remove TargetBaseAlign - return !(Allows && Fast) && (Alignment % SzInBytes) != 0 && - (Alignment % TargetBaseAlign) != 0; + return !Allows || !Fast; }