-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU][GlobaISel] wrap the load-splitting code in RegBank selection with condition #98966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with condition The load-splitting code in RegBank selection is only relevant to those listed address-space. Signed-off-by: gangc <[email protected]>
@llvm/pr-subscribers-backend-amdgpu Author: Gang Chen (cmc-rep) ChangesThe load-splitting code in RegBank selection is only relevant to those listed address-spaces because there are cases in those address-spaces in which we are not sure how far to split during legalization Full diff: https://github.com/llvm/llvm-project/pull/98966.diff 1 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
index 9e7694f41d6b8..71b88c011b6c2 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp
@@ -1059,6 +1059,7 @@ bool AMDGPURegisterBankInfo::applyMappingLoad(
Register DstReg = MI.getOperand(0).getReg();
const LLT LoadTy = MRI.getType(DstReg);
unsigned LoadSize = LoadTy.getSizeInBits();
+ MachineMemOperand *MMO = *MI.memoperands_begin();
const unsigned MaxNonSmrdLoadSize = 128;
const RegisterBank *DstBank =
@@ -1069,7 +1070,6 @@ bool AMDGPURegisterBankInfo::applyMappingLoad(
if (LoadSize != 32 && (LoadSize != 96 || Subtarget.hasScalarDwordx3Loads()))
return false;
- MachineMemOperand *MMO = *MI.memoperands_begin();
const unsigned MemSize = 8 * MMO->getSize().getValue();
// Scalar loads of size 8 or 16 bit with proper alignment may be widened to
// 32 bit. Check to see if we need to widen the memory access, 8 or 16 bit
@@ -1142,25 +1142,31 @@ bool AMDGPURegisterBankInfo::applyMappingLoad(
if (SrcRegs.empty())
SrcRegs.push_back(MI.getOperand(1).getReg());
- assert(LoadSize % MaxNonSmrdLoadSize == 0);
-
// RegBankSelect only emits scalar types, so we need to reset the pointer
// operand to a pointer type.
Register BasePtrReg = SrcRegs[0];
LLT PtrTy = MRI.getType(MI.getOperand(1).getReg());
MRI.setType(BasePtrReg, PtrTy);
- unsigned NumSplitParts = LoadTy.getSizeInBits() / MaxNonSmrdLoadSize;
- const LLT LoadSplitTy = LoadTy.divide(NumSplitParts);
- ApplyRegBankMapping O(B, *this, MRI, &AMDGPU::VGPRRegBank);
- LegalizerHelper Helper(B.getMF(), O, B);
-
- if (LoadTy.isVector()) {
- if (Helper.fewerElementsVector(MI, 0, LoadSplitTy) != LegalizerHelper::Legalized)
- return false;
- } else {
- if (Helper.narrowScalar(MI, 0, LoadSplitTy) != LegalizerHelper::Legalized)
- return false;
+ // the following are the loads not splitted enough during legalization
+ // because it was not clear they are smem-load or vmem-load
+ if (MMO->getAddrSpace() == AMDGPUAS::GLOBAL_ADDRESS ||
+ MMO->getAddrSpace() == AMDGPUAS::CONSTANT_ADDRESS ||
+ MMO->getAddrSpace() == AMDGPUAS::CONSTANT_ADDRESS_32BIT ||
+ MMO->getAddrSpace() == AMDGPUAS::BUFFER_RESOURCE) {
+ assert(LoadSize % MaxNonSmrdLoadSize == 0);
+ unsigned NumSplitParts = LoadTy.getSizeInBits() / MaxNonSmrdLoadSize;
+ const LLT LoadSplitTy = LoadTy.divide(NumSplitParts);
+ ApplyRegBankMapping O(B, *this, MRI, &AMDGPU::VGPRRegBank);
+ LegalizerHelper Helper(B.getMF(), O, B);
+ if (LoadTy.isVector()) {
+ if (Helper.fewerElementsVector(MI, 0, LoadSplitTy) !=
+ LegalizerHelper::Legalized)
+ return false;
+ } else {
+ if (Helper.narrowScalar(MI, 0, LoadSplitTy) != LegalizerHelper::Legalized)
+ return false;
+ }
}
MRI.setRegBank(DstReg, AMDGPU::VGPRRegBank);
|
arsenm
reviewed
Jul 23, 2024
@arsenm I have updated the PR |
arsenm
approved these changes
Jul 24, 2024
yuxuanchen1997
pushed a commit
that referenced
this pull request
Jul 25, 2024
… with condition (#98966) Summary: The load-splitting code in RegBank selection is only relevant to those listed address-spaces because there are cases in those address-spaces in which we are not sure how far to split during legalization --------- Signed-off-by: gangc <[email protected]> Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250673
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The load-splitting code in RegBank selection is only relevant to those listed address-spaces because there are cases in those address-spaces in which we are not sure how far to split during legalization