Skip to content

Commit 67aec2f

Browse files
committed
[llvm] Remove no-op ptr-to-ptr casts (NFC)
Remove calls to CreatePointerCast which are just doing no-op ptr-to-ptr bitcasts. Opaque ptr cleanup effort (NFC).
1 parent 93b14c3 commit 67aec2f

File tree

3 files changed

+3
-14
lines changed

3 files changed

+3
-14
lines changed

llvm/lib/CodeGen/CodeGenPrepare.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6188,8 +6188,6 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
61886188
// Generate a new GEP to replace the current one.
61896189
LLVMContext &Ctx = GEP->getContext();
61906190
Type *PtrIdxTy = DL->getIndexType(GEP->getType());
6191-
Type *I8PtrTy =
6192-
PointerType::get(Ctx, GEP->getType()->getPointerAddressSpace());
61936191
Type *I8Ty = Type::getInt8Ty(Ctx);
61946192

61956193
if (!NewBaseGEP) {
@@ -6200,16 +6198,10 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
62006198

62016199
IRBuilder<> Builder(GEP);
62026200
Value *NewGEP = NewBaseGEP;
6203-
if (Offset == BaseOffset) {
6204-
if (GEP->getType() != I8PtrTy)
6205-
NewGEP = Builder.CreatePointerCast(NewGEP, GEP->getType());
6206-
} else {
6201+
if (Offset != BaseOffset) {
62076202
// Calculate the new offset for the new GEP.
62086203
Value *Index = ConstantInt::get(PtrIdxTy, Offset - BaseOffset);
62096204
NewGEP = Builder.CreateGEP(I8Ty, NewBaseGEP, Index);
6210-
6211-
if (GEP->getType() != I8PtrTy)
6212-
NewGEP = Builder.CreatePointerCast(NewGEP, GEP->getType());
62136205
}
62146206
replaceAllUsesWith(GEP, NewGEP, FreshBBs, IsHugeFunc);
62156207
LargeOffsetGEPID.erase(GEP);

llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,11 +562,10 @@ bool AMDGPULibCalls::fold_read_write_pipe(CallInst *CI, IRBuilder<> &B,
562562
if (!F)
563563
return false;
564564

565-
auto *BCast = B.CreatePointerCast(PtrArg, PtrTy);
566565
SmallVector<Value *, 6> Args;
567566
for (unsigned I = 0; I != PtrArgLoc; ++I)
568567
Args.push_back(CI->getArgOperand(I));
569-
Args.push_back(BCast);
568+
Args.push_back(PtrArg);
570569

571570
auto *NCI = B.CreateCall(F, Args);
572571
NCI->setAttributes(CI->getAttributes());

llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,7 @@ Value *X86LowerAMXIntrinsics::createTileLoadStoreLoops(
184184
Value *CurrentColZExt = B.CreateZExt(CurrentCol, Stride->getType());
185185
Value *Offset =
186186
B.CreateAdd(B.CreateMul(CurrentRowZExt, Stride), CurrentColZExt);
187-
unsigned AS = cast<PointerType>(Ptr->getType())->getAddressSpace();
188-
Value *EltBasePtr = B.CreatePointerCast(Ptr, PointerType::get(EltTy, AS));
189-
Value *EltPtr = B.CreateGEP(EltTy, EltBasePtr, Offset);
187+
Value *EltPtr = B.CreateGEP(EltTy, Ptr, Offset);
190188
Value *Idx = B.CreateAdd(B.CreateMul(CurrentRow, B.getInt16(16)), CurrentCol);
191189
if (IsTileLoad) {
192190
// tileload.scalarize.rows.header:

0 commit comments

Comments
 (0)