[llvm] 67aec2f - [llvm] Remove no-op ptr-to-ptr casts (NFC)
Youngsuk Kim via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 15 09:09:55 PST 2023
Author: Youngsuk Kim
Date: 2023-12-15T11:04:48-06:00
New Revision: 67aec2f58bf1568bb1c68d4906bc3c0103ff3c98
URL: https://github.com/llvm/llvm-project/commit/67aec2f58bf1568bb1c68d4906bc3c0103ff3c98
DIFF: https://github.com/llvm/llvm-project/commit/67aec2f58bf1568bb1c68d4906bc3c0103ff3c98.diff
LOG: [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).
Added:
Modified:
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index e06b430b3d287f..6e99fb133e26a9 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -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) {
@@ -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);
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
index 5c66fd2b180f76..0c21382e5c225e 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULibCalls.cpp
@@ -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());
diff --git a/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp b/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
index e3b03e981202ed..591a76e6fd6cc7 100644
--- a/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
+++ b/llvm/lib/Target/X86/X86LowerAMXIntrinsics.cpp
@@ -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:
More information about the llvm-commits
mailing list