From ba1e845c211893c3c2f392913232b176908ea7a2 Mon Sep 17 00:00:00 2001 From: Stanislav Mekhanoshin Date: Wed, 31 Jul 2019 16:33:11 +0000 Subject: [AMDGPU] Fix for vectorizer crash with pointers of different size When vectorizer strips pointers it can eventually end up with pointers of two different sizes, then SCEV will crash. Differential Revision: https://reviews.llvm.org/D65480 llvm-svn: 367443 --- llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp') diff --git a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp index 4273080ddd9..f799a45f567 100644 --- a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -339,11 +339,16 @@ bool Vectorizer::areConsecutivePointers(Value *PtrA, Value *PtrB, const APInt &PtrDelta, unsigned Depth) const { unsigned PtrBitWidth = DL.getPointerTypeSizeInBits(PtrA->getType()); + unsigned PtrAS = PtrA->getType()->getPointerAddressSpace(); APInt OffsetA(PtrBitWidth, 0); APInt OffsetB(PtrBitWidth, 0); PtrA = PtrA->stripAndAccumulateInBoundsConstantOffsets(DL, OffsetA); PtrB = PtrB->stripAndAccumulateInBoundsConstantOffsets(DL, OffsetB); + if (PtrA->getType()->getPointerAddressSpace() != PtrAS || + PtrB->getType()->getPointerAddressSpace() != PtrAS) + return false; + APInt OffsetDelta = OffsetB - OffsetA; // Check if they are based on the same pointer. That makes the offsets -- cgit v1.2.3