diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-07-01 02:09:38 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-07-01 02:09:38 +0000 |
commit | 0101ecade0e37741b4d2fe9126b0bb978a0bf925 (patch) | |
tree | 93fd828cf59959cccfe15f28af94ac80f17e4737 /llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp | |
parent | 370e8226c74b94744b8accded70ef6377d50eccb (diff) | |
download | bcm5719-llvm-0101ecade0e37741b4d2fe9126b0bb978a0bf925.tar.gz bcm5719-llvm-0101ecade0e37741b4d2fe9126b0bb978a0bf925.zip |
LoadStoreVectorizer: Don't increase alignment with no align set
If no alignment was set on the load/stores, it would vectorize
to the new type even though this increases the default alignment.
llvm-svn: 274323
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp index 0168d78145a..b56d0ed0c9b 100644 --- a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -71,6 +71,22 @@ private: unsigned getPointerAddressSpace(Value *I); + unsigned getAlignment(LoadInst *LI) const { + unsigned Align = LI->getAlignment(); + if (Align != 0) + return Align; + + return DL.getABITypeAlignment(LI->getType()); + } + + unsigned getAlignment(StoreInst *SI) const { + unsigned Align = SI->getAlignment(); + if (Align != 0) + return Align; + + return DL.getABITypeAlignment(SI->getValueOperand()->getType()); + } + bool isConsecutiveAccess(Value *A, Value *B); /// Reorders the users of I after vectorization to ensure that I dominates its @@ -648,7 +664,7 @@ bool Vectorizer::vectorizeStoreChain(ArrayRef<Value *> Chain) { ); // Check alignment restrictions. - unsigned Alignment = S0->getAlignment(); + unsigned Alignment = getAlignment(S0); // If the store is going to be misaligned, don't vectorize it. // TODO: Check TLI.allowsMisalignedMemoryAccess @@ -776,7 +792,7 @@ bool Vectorizer::vectorizeLoadChain(ArrayRef<Value *> Chain) { } // Check alignment restrictions. - unsigned Alignment = L0->getAlignment(); + unsigned Alignment = getAlignment(L0); // If the load is going to be misaligned, don't vectorize it. // TODO: Check TLI.allowsMisalignedMemoryAccess and remove TargetBaseAlign. |