[PATCH] D156736: [LV][LSV][SLP] Drop some typed pointer bitcasts
Bjorn Pettersson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 31 13:39:59 PDT 2023
bjope created this revision.
Herald added subscribers: artagnon, vporpo, hiraditya.
Herald added a project: All.
bjope requested review of this revision.
Herald added a subscriber: wangpc.
Herald added a project: LLVM.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D156736
Files:
llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -10550,28 +10550,23 @@
}
case Instruction::Store: {
auto *SI = cast<StoreInst>(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<User>(VecPtr) : ST,
- FoundLane));
+ unsigned FoundLane = Entry->findLaneForValue(Ptr);
+ ExternalUses.push_back(ExternalUser(Ptr, ST, FoundLane));
}
Value *V = propagateMetadata(ST, E->Scalars);
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2630,11 +2630,7 @@
if (auto *gep = dyn_cast<GetElementPtrInst>(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);
Index: llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
@@ -900,9 +900,9 @@
// 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 @@
// 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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156736.545784.patch
Type: text/x-patch
Size: 3707 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230731/5852e0fb/attachment.bin>
More information about the llvm-commits
mailing list