diff --git a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp index 260d7889906b2..73a8070267192 100644 --- a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -900,9 +900,9 @@ bool Vectorizer::vectorizeChain(Chain &C) { // Chain is in offset order, so C[0] is the instr with the lowest offset, // i.e. the root of the vector. - Value *Bitcast = Builder.CreateBitCast( - getLoadStorePointerOperand(C[0].Inst), VecTy->getPointerTo(AS)); - VecInst = Builder.CreateAlignedLoad(VecTy, Bitcast, Alignment); + VecInst = Builder.CreateAlignedLoad(VecTy, + getLoadStorePointerOperand(C[0].Inst), + Alignment); unsigned VecIdx = 0; for (const ChainElem &E : C) { @@ -976,8 +976,7 @@ bool Vectorizer::vectorizeChain(Chain &C) { // i.e. the root of the vector. VecInst = Builder.CreateAlignedStore( Vec, - Builder.CreateBitCast(getLoadStorePointerOperand(C[0].Inst), - VecTy->getPointerTo(AS)), + getLoadStorePointerOperand(C[0].Inst), Alignment); } diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 7257b62452a09..66e9b0e6912a8 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -2630,11 +2630,7 @@ void InnerLoopVectorizer::vectorizeInterleaveGroup( if (auto *gep = dyn_cast(AddrPart->stripPointerCasts())) InBounds = gep->isInBounds(); AddrPart = Builder.CreateGEP(ScalarTy, AddrPart, Idx, "", InBounds); - - // Cast to the vector pointer type. - unsigned AddressSpace = AddrPart->getType()->getPointerAddressSpace(); - Type *PtrTy = VecTy->getPointerTo(AddressSpace); - AddrParts.push_back(Builder.CreateBitCast(AddrPart, PtrTy)); + AddrParts.push_back(AddrPart); } State.setDebugLocFromInst(Instr); diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp index 564cdaf6d9210..7f8460f4a9e23 100644 --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp @@ -10256,8 +10256,7 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) { case Instruction::ExtractValue: { auto *LI = cast(E->getSingleOperand(0)); Builder.SetInsertPoint(LI); - auto *PtrTy = PointerType::get(VecTy, LI->getPointerAddressSpace()); - Value *Ptr = Builder.CreateBitCast(LI->getOperand(0), PtrTy); + Value *Ptr = LI->getPointerOperand(); LoadInst *V = Builder.CreateAlignedLoad(VecTy, Ptr, LI->getAlign()); Value *NewV = propagateMetadata(V, E->Scalars); NewV = FinalShuffle(NewV, E); @@ -10599,28 +10598,23 @@ Value *BoUpSLP::vectorizeTree(TreeEntry *E) { } case Instruction::Store: { auto *SI = cast(VL0); - unsigned AS = SI->getPointerAddressSpace(); setInsertPointAfterBundle(E); Value *VecValue = vectorizeOperand(E, 0); VecValue = FinalShuffle(VecValue, E); - Value *ScalarPtr = SI->getPointerOperand(); - Value *VecPtr = Builder.CreateBitCast( - ScalarPtr, VecValue->getType()->getPointerTo(AS)); + Value *Ptr = SI->getPointerOperand(); StoreInst *ST = - Builder.CreateAlignedStore(VecValue, VecPtr, SI->getAlign()); + Builder.CreateAlignedStore(VecValue, Ptr, SI->getAlign()); - // The pointer operand uses an in-tree scalar, so add the new BitCast or - // StoreInst to ExternalUses to make sure that an extract will be - // generated in the future. - if (TreeEntry *Entry = getTreeEntry(ScalarPtr)) { + // The pointer operand uses an in-tree scalar, so add the new StoreInst to + // ExternalUses to make sure that an extract will be generated in the + // future. + if (TreeEntry *Entry = getTreeEntry(Ptr)) { // Find which lane we need to extract. - unsigned FoundLane = Entry->findLaneForValue(ScalarPtr); - ExternalUses.push_back(ExternalUser( - ScalarPtr, ScalarPtr != VecPtr ? cast(VecPtr) : ST, - FoundLane)); + unsigned FoundLane = Entry->findLaneForValue(Ptr); + ExternalUses.push_back(ExternalUser(Ptr, ST, FoundLane)); } Value *V = propagateMetadata(ST, E->Scalars);