diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2023-02-11 12:38:04 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2023-02-11 12:38:11 +0000 |
commit | e3b557809604d036af6e00c60f012c2025b59a5e (patch) | |
tree | 8a11ba2269a3b669601e2fd41145b174008f4da8 /llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp | |
parent | 08e8dd7b9db7bb4a9de26d44c1cbfd24e869c014 (diff) | |
download | src-e3b557809604d036af6e00c60f012c2025b59a5e.tar.gz src-e3b557809604d036af6e00c60f012c2025b59a5e.zip |
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp index f59fc3a6dd60..0b7fc853dc1b 100644 --- a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -186,8 +186,11 @@ private: SmallPtrSet<Instruction *, 16> *InstructionsProcessed); /// Check if this load/store access is misaligned accesses. + /// Returns a \p RelativeSpeed of an operation if allowed suitable to + /// compare to another result for the same \p AddressSpace and potentially + /// different \p Alignment and \p SzInBytes. bool accessIsMisaligned(unsigned SzInBytes, unsigned AddressSpace, - Align Alignment); + Align Alignment, unsigned &RelativeSpeed); }; class LoadStoreVectorizerLegacyPass : public FunctionPass { @@ -1078,8 +1081,14 @@ bool Vectorizer::vectorizeStoreChain( InstructionsProcessed->insert(Chain.begin(), Chain.end()); // If the store is going to be misaligned, don't vectorize it. - if (accessIsMisaligned(SzInBytes, AS, Alignment)) { + unsigned RelativeSpeed; + if (accessIsMisaligned(SzInBytes, AS, Alignment, RelativeSpeed)) { if (S0->getPointerAddressSpace() != DL.getAllocaAddrSpace()) { + unsigned SpeedBefore; + accessIsMisaligned(EltSzInBytes, AS, Alignment, SpeedBefore); + if (SpeedBefore > RelativeSpeed) + return false; + auto Chains = splitOddVectorElts(Chain, Sz); bool Vectorized = false; Vectorized |= vectorizeStoreChain(Chains.first, InstructionsProcessed); @@ -1231,8 +1240,14 @@ bool Vectorizer::vectorizeLoadChain( InstructionsProcessed->insert(Chain.begin(), Chain.end()); // If the load is going to be misaligned, don't vectorize it. - if (accessIsMisaligned(SzInBytes, AS, Alignment)) { + unsigned RelativeSpeed; + if (accessIsMisaligned(SzInBytes, AS, Alignment, RelativeSpeed)) { if (L0->getPointerAddressSpace() != DL.getAllocaAddrSpace()) { + unsigned SpeedBefore; + accessIsMisaligned(EltSzInBytes, AS, Alignment, SpeedBefore); + if (SpeedBefore > RelativeSpeed) + return false; + auto Chains = splitOddVectorElts(Chain, Sz); bool Vectorized = false; Vectorized |= vectorizeLoadChain(Chains.first, InstructionsProcessed); @@ -1316,15 +1331,15 @@ bool Vectorizer::vectorizeLoadChain( } bool Vectorizer::accessIsMisaligned(unsigned SzInBytes, unsigned AddressSpace, - Align Alignment) { + Align Alignment, unsigned &RelativeSpeed) { + RelativeSpeed = 0; if (Alignment.value() % SzInBytes == 0) return false; - bool Fast = false; bool Allows = TTI.allowsMisalignedMemoryAccesses(F.getParent()->getContext(), SzInBytes * 8, AddressSpace, - Alignment, &Fast); + Alignment, &RelativeSpeed); LLVM_DEBUG(dbgs() << "LSV: Target said misaligned is allowed? " << Allows - << " and fast? " << Fast << "\n";); - return !Allows || !Fast; + << " with relative speed = " << RelativeSpeed << '\n';); + return !Allows || !RelativeSpeed; } |