-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AMDGPU] Add commute for some VOP3 inst #121326
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
Changes from 21 commits
f0877bb
ae5f1e8
df6903c
ada83d6
c599af0
3a83ae5
5c9d065
d3f00dc
0e60298
707474f
79219d1
288ead2
4becc58
53b370a
0b746a8
785921f
6955a86
5e15e72
004a82d
dc2739f
378c02c
49ae569
161a2b9
4d569ae
1689c1e
328e566
9faf423
19b8ad4
cc3a125
0a89dc9
d8e6cb7
3c7bd89
bf1da57
789092d
6c35280
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2749,6 +2749,67 @@ static MachineInstr *swapRegAndNonRegOperand(MachineInstr &MI, | |||||||||
| return &MI; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| static MachineInstr *swapImmOperands(MachineInstr &MI, | ||||||||||
| MachineOperand &NonRegOp1, | ||||||||||
| MachineOperand &NonRegOp2) { | ||||||||||
| unsigned TargetFlags = NonRegOp1.getTargetFlags(); | ||||||||||
| int64_t NonRegVal = NonRegOp1.getImm(); | ||||||||||
|
|
||||||||||
| NonRegOp1.setImm(NonRegOp2.getImm()); | ||||||||||
| NonRegOp2.setImm(NonRegVal); | ||||||||||
| NonRegOp1.setTargetFlags(NonRegOp2.getTargetFlags()); | ||||||||||
| NonRegOp2.setTargetFlags(TargetFlags); | ||||||||||
| return &MI; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| bool SIInstrInfo::isLegalToSwap(const MachineInstr &MI, | ||||||||||
| unsigned OpIdx0, const MachineOperand *MO0, | ||||||||||
| unsigned OpIdx1, const MachineOperand *MO1) const { | ||||||||||
| const MCInstrDesc &InstDesc = MI.getDesc(); | ||||||||||
| const MCOperandInfo &OpInfo0 = InstDesc.operands()[OpIdx0]; | ||||||||||
| const MCOperandInfo &OpInfo1 = InstDesc.operands()[OpIdx1]; | ||||||||||
| const TargetRegisterClass *DefinedRC1 = | ||||||||||
| OpInfo1.RegClass != -1 ? RI.getRegClass(OpInfo1.RegClass) : nullptr; | ||||||||||
| const TargetRegisterClass *DefinedRC0 = | ||||||||||
| OpInfo1.RegClass != -1 ? RI.getRegClass(OpInfo0.RegClass) : nullptr; | ||||||||||
|
|
||||||||||
| unsigned Opc = MI.getOpcode(); | ||||||||||
| int Src0Idx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src0); | ||||||||||
| if (Src0Idx == -1) { | ||||||||||
| // VOPD V_DUAL_* instructions use different operand names. | ||||||||||
| Src0Idx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src0X); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // Swap doesn't breach constantbus or literal limits | ||||||||||
|
||||||||||
| // Swap doesn't breach constantbus or literal limits | |
| // Swap doesn't breach constant bus or literal limits |
Outdated
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.
| // FIX-ME: After gfx9, literal can be in place other than Src0 | |
| // FIXME: After gfx9, literal can be in place other than Src0 |
Outdated
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 need to check 64bit literals since swapping does not bring new | |
| // 64bit literals into current instruction to fold to 32bit | |
| // No need to check 64-bit literals since swapping does not bring new | |
| // 64-bit literals into current instruction to fold to 32-bit |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,6 @@ name: not_shrink_icmp | |
| body: | | ||
| bb.0: | ||
| ; GCN-LABEL: name: not_shrink_icmp | ||
| ; GCN: S_CMP_GT_I32 1, 65, implicit-def $scc | ||
| ; GCN: S_CMP_LT_I32 65, 1, implicit-def $scc | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pointless swap but probably not this patch's problem |
||
| S_CMP_GT_I32 1, 65, implicit-def $scc | ||
| ... | ||
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.
This VOPD case is still missing a test
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 , I re-searched all generated instruction, but cannot find a VOPD instruction that is commutable with operand names as $src0X...
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.
Then remove this handling?