[llvm] 4202ad5 - AMDGPU: Don't create a pointer bitcast in AMDGPULateCodeGenPrepare
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 29 08:01:41 PDT 2023
Author: Matt Arsenault
Date: 2023-04-29T10:34:21-04:00
New Revision: 4202ad5d949bf682aa0927801aebed8289532263
URL: https://github.com/llvm/llvm-project/commit/4202ad5d949bf682aa0927801aebed8289532263
DIFF: https://github.com/llvm/llvm-project/commit/4202ad5d949bf682aa0927801aebed8289532263.diff
LOG: AMDGPU: Don't create a pointer bitcast in AMDGPULateCodeGenPrepare
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp b/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
index 2fc68a142396..7351a9c8f7b6 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp
@@ -156,18 +156,14 @@ bool AMDGPULateCodeGenPrepare::visitLoadInst(LoadInst &LI) {
IRBuilder<> IRB(&LI);
IRB.SetCurrentDebugLocation(LI.getDebugLoc());
- unsigned AS = LI.getPointerAddressSpace();
unsigned LdBits = DL->getTypeStoreSize(LI.getType()) * 8;
auto IntNTy = Type::getIntNTy(LI.getContext(), LdBits);
- PointerType *Int32PtrTy = Type::getInt32PtrTy(LI.getContext(), AS);
- PointerType *Int8PtrTy = Type::getInt8PtrTy(LI.getContext(), AS);
- auto *NewPtr = IRB.CreateBitCast(
- IRB.CreateConstGEP1_64(
- IRB.getInt8Ty(),
- IRB.CreatePointerBitCastOrAddrSpaceCast(Base, Int8PtrTy),
- Offset - Adjust),
- Int32PtrTy);
+ auto *NewPtr = IRB.CreateConstGEP1_64(
+ IRB.getInt8Ty(),
+ IRB.CreateAddrSpaceCast(Base, LI.getPointerOperand()->getType()),
+ Offset - Adjust);
+
LoadInst *NewLd = IRB.CreateAlignedLoad(IRB.getInt32Ty(), NewPtr, Align(4));
NewLd->copyMetadata(LI);
NewLd->setMetadata(LLVMContext::MD_range, nullptr);
More information about the llvm-commits
mailing list