-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[AMDGPU] fix up vop3p gisel errors #136262
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
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-backend-amdgpu Author: None (Shoreshen) ChangesThis is a fix up for patch #130234, which is reverted in #136249 The main reason of building failure are:
/home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp:4554:1: error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type]
SmallVector<std::pair<const MachineOperand *, SrcStatus>, 4> Statlist;
SmallVector<std::pair<const MachineOperand *, SrcStatus>> Statlist;
auto [Op, Mods] = selectVOP3PModsImpl(&Root, MRI, IsDOT);
auto Results = selectVOP3PModsImpl(&Root, MRI, IsDOT);
|
@llvm/pr-subscribers-llvm-globalisel Author: None (Shoreshen) ChangesThis is a fix up for patch #130234, which is reverted in #136249 The main reason of building failure are:
/home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp:4554:1: error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type]
SmallVector<std::pair<const MachineOperand *, SrcStatus>, 4> Statlist;
SmallVector<std::pair<const MachineOperand *, SrcStatus>> Statlist;
auto [Op, Mods] = selectVOP3PModsImpl(&Root, MRI, IsDOT);
auto Results = selectVOP3PModsImpl(&Root, MRI, IsDOT);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes build errors related to AMDGPU instruction selection and adjusts the test configuration for llvm-readobj output decoding.
- Updated the decoding from ASCII to UTF-8 in the lit test configuration.
- Modified the signature of selectVOP3PModsImpl (and related function) to correct the return type that was causing build conversion issues.
Reviewed Changes
Copilot reviewed 3 out of 7 changed files in this pull request and generated no comments.
File | Description |
---|---|
llvm/test/lit.cfg.py | Updated stdout decoding to utf-8 for reliable string interpretation. |
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h | Changed function return types to resolve type mismatch in the build. |
Files not reviewed (4)
- llvm/test/CodeGen/AMDGPU/GlobalISel/fmul.v2f16.ll: Language not supported
- llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.sdot2.ll: Language not supported
- llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.udot2.ll: Language not supported
- llvm/test/CodeGen/AMDGPU/strict_fsub.f16.ll: Language not supported
Comments suppressed due to low confidence (2)
llvm/test/lit.cfg.py:469
- Ensure that switching the decoding from 'ascii' to 'utf-8' is intentional and that the llvm-readobj output consistently uses UTF-8 encoding across all environments.
readobj_out = readobj_cmd.stdout.read().decode("utf-8")
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h:190
- The change in the return type of selectVOP3PModsImpl to use a 'const MachineOperand *' instead of 'Register' is intended to resolve conversion errors; please verify that all corresponding call sites in the implementation file have been updated accordingly.
std::pair<const MachineOperand *, unsigned>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes build failures in the AMDGPUInstructionSelector by updating function signatures to remove structured bindings and adjust parameter/return types.
- Updated selectVOP3PModsImpl signature from taking a Register to a const MachineOperand* and modified its return type accordingly
- Replaced structured binding in selectVOP3PRetHelper with explicit variable extraction for clearer, C++20 compatible code
Files not reviewed (4)
- llvm/test/CodeGen/AMDGPU/GlobalISel/fmul.v2f16.ll: Language not supported
- llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.sdot2.ll: Language not supported
- llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.udot2.ll: Language not supported
- llvm/test/CodeGen/AMDGPU/strict_fsub.f16.ll: Language not supported
Comments suppressed due to low confidence (2)
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h:190
- Please verify that the updated parameter and return types for selectVOP3PModsImpl are consistently reflected in its implementation and all invocations.
std::pair<const MachineOperand *, unsigned> selectVOP3PModsImpl(const MachineOperand *Op, const MachineRegisterInfo &MRI, bool IsDOT = false) const;
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h:193
- Ensure that the conversion from structured bindings to explicit variable extraction in selectVOP3PRetHelper is properly implemented in the source file.
InstructionSelector::ComplexRendererFns selectVOP3PRetHelper(MachineOperand &Root, bool IsDOT = false) const;
} | ||
|
||
static std::optional<std::pair<const MachineOperand *, SrcStatus>> | ||
retOpStat(const MachineOperand *Op, SrcStatus Stat, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we pass MachineOperand
as a reference instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @tgymnich, maybe only part of it. There are some places that using reference will cause error, such as:
static SmallVector<std::pair<const MachineOperand *, SrcStatus>>
getSrcStats(const MachineOperand *Op, const MachineRegisterInfo &MRI,
searchOptions SearchOptions, int MaxDepth = 6) {
...
while (Depth <= MaxDepth && Curr.has_value()) {
...
Curr = calcNextStatus(Curr.value(), MRI);
}
...
}
If I use reference in this place, the =
will change the original operand.
Currently I think it is simpler to use pointer in all place.
// [CurrHi, CurrLo] = [-OpHi, -OpLo](2 x Type) | ||
// [SrcHi, SrcLo] = [-OpHi, -OpLo] | ||
return SrcStatus::IS_BOTH_NEG; | ||
} else if (NegType == TypeClass::SCALAR) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No else after return
if (!Op->isReg() || Op->getReg().isPhysical()) | ||
return TypeClass::NONE_OF_LISTED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These cases should not reach here. Gisel code should generally operate in terms of Registers, and it never should need to interact with physical registers
if (Stat != SrcStatus::INVALID && | ||
((Op->isReg() && !(Op->getReg().isPhysical())) || Op->isImm() || | ||
Op->isCImm() || Op->isFPImm())) { | ||
return std::optional<std::pair<const MachineOperand *, SrcStatus>>( | ||
{Op, Stat}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of these cases should need handling
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @arsenm , if I'm not wrong the input and output of the block may have psychical regs. And some time the input and output can be the same physical regs. this will cause infinite loop...
case AMDGPU::G_CONSTANT: | ||
case AMDGPU::G_FCONSTANT: | ||
case AMDGPU::COPY: | ||
return retOpStat(&MI->getOperand(1), Curr.second, Curr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't try to treat the leaf constants similar to a copy, treat them specially and directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @arsenm , do you mean like this:
switch (Opc) {
case AMDGPU::G_CONSTANT:
case AMDGPU::G_FCONSTANT:
return retOpStat(&MI->getOperand(1), Curr.second, Curr);
case AMDGPU::G_BITCAST:
case AMDGPU::COPY:
return retOpStat(&MI->getOperand(1), Curr.second, Curr);
case AMDGPU::G_FNEG:
return retOpStat(&MI->getOperand(1),
getNegStatus(Curr.first, Curr.second, MRI), Curr);
default:
break;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses build errors encountered in AMDGPU's VOP3P instruction selection by updating function signatures and removing structured bindings.
- Updated selectVOP3PModsImpl to return a pair containing a pointer instead of a Register.
- Introduced selectVOP3PRetHelper to eliminate structured bindings and accommodate C++20 extension issues.
Files not reviewed (4)
- llvm/test/CodeGen/AMDGPU/GlobalISel/fmul.v2f16.ll: Language not supported
- llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.sdot2.ll: Language not supported
- llvm/test/CodeGen/AMDGPU/GlobalISel/llvm.amdgcn.udot2.ll: Language not supported
- llvm/test/CodeGen/AMDGPU/strict_fsub.f16.ll: Language not supported
Comments suppressed due to low confidence (2)
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h:189
- [nitpick] The updated signature of selectVOP3PModsImpl now uses a pointer instead of a Register; consider adding inline documentation to clarify this design decision and ensure consistency with its usage in the implementation.
std::pair<const MachineOperand *, unsigned> selectVOP3PModsImpl(const MachineOperand *Op, const MachineRegisterInfo &MRI,
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.h:193
- [nitpick] The new selectVOP3PRetHelper function is introduced to avoid structured bindings; consider providing a comment or documentation noting its relationship to selectVOP3PModsImpl to guide future maintenance.
InstructionSelector::ComplexRendererFns selectVOP3PRetHelper(MachineOperand &Root, bool IsDOT = false) const;
This is a fix up for patch #130234, which is reverted in #136249
The main reason of building failure are:
Both error cannot be reproduced at my local machine, the fix applied are:
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
functiongetSrcStats
replacellvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
functionAMDGPUInstructionSelector::selectVOP3PRetHelper
replaceThese change hasn't be testified since both errors cannot be reproduced in local