Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
What's the reasoning for this? Won't this break chains of REG_SEQUENCE? In particular I do expect to see some REG_SEQUENCE (REG_SEQUENCE), (REG_SEQUENCE) patterns
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | ||
---|---|---|
4758 ↗ | (On Diff #412398) | isUnknownRegClass? |
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | ||
---|---|---|
4761 ↗ | (On Diff #412398) | Why do you need to test isVariadic here()? Surely as long as you compare OpIdx against Desc.getNumOperands() (not MI.getNumOperands()) you're OK? |
Currently skipping it to avoid a crash that occurred with REG_SEQUENCE(REG_SEQUENCE) while trying to look for the regclass @OpIdx from the UseMI's MCInstrDesc.
These special cases involving target-independent and/or variadic instructions should be handled separately.
This folding will take place only when the regclass at OpIdx is a vectorSuperClass https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AMDGPU/SIFoldOperands.cpp#L1603
Currently, we don't select any AV operands and I guess it is ok to skip them.
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | ||
---|---|---|
4758 ↗ | (On Diff #412398) | Will use |
4761 ↗ | (On Diff #412398) | No, OpIdx >= Desc.getNumOperands() didn't hold true when I checked the case REG_SEQUENCE (REG_SEQUENCE). Is it because the passed Op index is already adjusted from UseMI->getOperand(0)? |
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | ||
---|---|---|
4761 ↗ | (On Diff #412398) | Even variadic instructions shall have proper operand description before the variadic part starts. |
Removed variadic instruction check.
Desc.OpInfo[OpIdx].RegClass == -1 will catch those invalid cases.
llvm/lib/Target/AMDGPU/SIInstrInfo.cpp | ||
---|---|---|
4760 ↗ | (On Diff #412876) | Just use MI.getDesc()? |
llvm/lib/Target/AMDGPU/SIFoldOperands.cpp | ||
---|---|---|
1604 | You could just use TargetInstrInfo::getRegClass(InstDesc, OpIdx, TRI, MF) instead of TRI->getRegClass and it would do all these checks for you already. |
llvm/lib/Target/AMDGPU/SIFoldOperands.cpp | ||
---|---|---|
1604 | We can't use that equivalent of getRegClass here. The call to adjustAllocatableRegClass inside it would change AV classes to V thereby disabling the folding in almost all valid cases. |
llvm/lib/Target/AMDGPU/SIFoldOperands.cpp | ||
---|---|---|
1604 | The call to adjustAllocatableRegClass is in the AMDGPU-specific getOpRegClass, not in the generic getRegClass. |
llvm/lib/Target/AMDGPU/SIFoldOperands.cpp | ||
---|---|---|
1604 | @foad thanks for pointing that generic function. We have some variants in SIInstrInfo.cpp to get regclass value from InstDesc. But SIInstrInfo::getRegClass(InstDesc, OpIdx, TRI, MF) seems to be working. Though it also has a call to adjustAllocatableRegClass, it is more restrained and appeared to be not missing any folding opportunity for loads/stores that failed earlier with the other variant. |
You could just use TargetInstrInfo::getRegClass(InstDesc, OpIdx, TRI, MF) instead of TRI->getRegClass and it would do all these checks for you already.