Skip to content

Commit

Permalink
[llvm] Remove no-op ptr-to-ptr casts (NFC)
Browse files Browse the repository at this point in the history
Remove calls to CreatePointerCast which are just doing no-op ptr-to-ptr
bitcasts.

Opaque ptr cleanup effort (NFC).
  • Loading branch information
JOE1994 committed Dec 15, 2023
1 parent 93b14c3 commit 67aec2f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
10 changes: 1 addition & 9 deletions llvm/lib/CodeGen/CodeGenPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6188,8 +6188,6 @@ bool CodeGenPrepare::splitLargeGEPOffsets() {
// Generate a new GEP to replace the current one.
LLVMContext &Ctx = GEP->getContext();
Type *PtrIdxTy = DL->getIndexType(GEP->getType());
Type *I8PtrTy =
PointerType::get(Ctx, GEP->getType()->getPointerAddressSpace());
Type *I8Ty = Type::getInt8Ty(Ctx);

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

IRBuilder<> Builder(GEP);
Value *NewGEP = NewBaseGEP;
if (Offset == BaseOffset) {
if (GEP->getType() != I8PtrTy)
NewGEP = Builder.CreatePointerCast(NewGEP, GEP->getType());
} else {
if (Offset != BaseOffset) {
// Calculate the new offset for the new GEP.
Value *Index = ConstantInt::get(PtrIdxTy, Offset - BaseOffset);
NewGEP = Builder.CreateGEP(I8Ty, NewBaseGEP, Index);

if (GEP->getType() != I8PtrTy)
NewGEP = Builder.CreatePointerCast(NewGEP, GEP->getType());
}
replaceAllUsesWith(GEP, NewGEP, FreshBBs, IsHugeFunc);
LargeOffsetGEPID.erase(GEP);
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,10 @@ bool AMDGPULibCalls::fold_read_write_pipe(CallInst *CI, IRBuilder<> &B,
if (!F)
return false;

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

auto *NCI = B.CreateCall(F, Args);
NCI->setAttributes(CI->getAttributes());
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ Value *X86LowerAMXIntrinsics::createTileLoadStoreLoops(
Value *CurrentColZExt = B.CreateZExt(CurrentCol, Stride->getType());
Value *Offset =
B.CreateAdd(B.CreateMul(CurrentRowZExt, Stride), CurrentColZExt);
unsigned AS = cast<PointerType>(Ptr->getType())->getAddressSpace();
Value *EltBasePtr = B.CreatePointerCast(Ptr, PointerType::get(EltTy, AS));
Value *EltPtr = B.CreateGEP(EltTy, EltBasePtr, Offset);
Value *EltPtr = B.CreateGEP(EltTy, Ptr, Offset);
Value *Idx = B.CreateAdd(B.CreateMul(CurrentRow, B.getInt16(16)), CurrentCol);
if (IsTileLoad) {
// tileload.scalarize.rows.header:
Expand Down

0 comments on commit 67aec2f

Please sign in to comment.