Skip to content

Commit e5c523e

Browse files
authored
[AMDGPU] Produce better memoperand for LDS DMA (#75247)
1) It was marked as volatile. This is not needed and the only reason it was done is because it is both load and store and handled together with atomics. Global load to LDS was marked as volatile just because buffer load was done that way. 2) Preserve at least LDS (store) pointer which we always have with the intrinsics. 3) Use PoisonValue instead of nullptr for load memop as a Value.
1 parent 94230ce commit e5c523e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,18 +1145,18 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
11451145
MachineMemOperand::MOStore |
11461146
MachineMemOperand::MODereferenceable;
11471147

1148-
// XXX - Should this be volatile without known ordering?
1149-
Info.flags |= MachineMemOperand::MOVolatile;
1150-
11511148
switch (IntrID) {
11521149
default:
1150+
// XXX - Should this be volatile without known ordering?
1151+
Info.flags |= MachineMemOperand::MOVolatile;
11531152
break;
11541153
case Intrinsic::amdgcn_raw_buffer_load_lds:
11551154
case Intrinsic::amdgcn_raw_ptr_buffer_load_lds:
11561155
case Intrinsic::amdgcn_struct_buffer_load_lds:
11571156
case Intrinsic::amdgcn_struct_ptr_buffer_load_lds: {
11581157
unsigned Width = cast<ConstantInt>(CI.getArgOperand(2))->getZExtValue();
11591158
Info.memVT = EVT::getIntegerVT(CI.getContext(), Width * 8);
1159+
Info.ptrVal = CI.getArgOperand(1);
11601160
return true;
11611161
}
11621162
}
@@ -1289,8 +1289,8 @@ bool SITargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
12891289
Info.opc = ISD::INTRINSIC_VOID;
12901290
unsigned Width = cast<ConstantInt>(CI.getArgOperand(2))->getZExtValue();
12911291
Info.memVT = EVT::getIntegerVT(CI.getContext(), Width * 8);
1292-
Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore |
1293-
MachineMemOperand::MOVolatile;
1292+
Info.ptrVal = CI.getArgOperand(1);
1293+
Info.flags |= MachineMemOperand::MOLoad | MachineMemOperand::MOStore;
12941294
return true;
12951295
}
12961296
case Intrinsic::amdgcn_ds_bvh_stack_rtn: {
@@ -9231,7 +9231,9 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op,
92319231
MachinePointerInfo LoadPtrI = LoadMMO->getPointerInfo();
92329232

92339233
MachinePointerInfo StorePtrI = LoadPtrI;
9234-
StorePtrI.V = nullptr;
9234+
LoadPtrI.V = PoisonValue::get(
9235+
PointerType::get(*DAG.getContext(), AMDGPUAS::GLOBAL_ADDRESS));
9236+
LoadPtrI.AddrSpace = AMDGPUAS::GLOBAL_ADDRESS;
92359237
StorePtrI.AddrSpace = AMDGPUAS::LOCAL_ADDRESS;
92369238

92379239
auto F = LoadMMO->getFlags() &
@@ -9309,6 +9311,8 @@ SDValue SITargetLowering::LowerINTRINSIC_VOID(SDValue Op,
93099311
MachinePointerInfo LoadPtrI = LoadMMO->getPointerInfo();
93109312
LoadPtrI.Offset = Op->getConstantOperandVal(5);
93119313
MachinePointerInfo StorePtrI = LoadPtrI;
9314+
LoadPtrI.V = PoisonValue::get(
9315+
PointerType::get(*DAG.getContext(), AMDGPUAS::GLOBAL_ADDRESS));
93129316
LoadPtrI.AddrSpace = AMDGPUAS::GLOBAL_ADDRESS;
93139317
StorePtrI.AddrSpace = AMDGPUAS::LOCAL_ADDRESS;
93149318
auto F = LoadMMO->getFlags() &

0 commit comments

Comments
 (0)