-
Notifications
You must be signed in to change notification settings - Fork 15k
[AMDGPU] Enable copy from VCC to SHARED_BASE. #164138
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
[AMDGPU] Enable copy from VCC to SHARED_BASE. #164138
Conversation
|
@llvm/pr-subscribers-backend-amdgpu Author: None (carlobertolli) ChangesFull diff: https://github.com/llvm/llvm-project/pull/164138.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 50447f48a628c..d1556cccf9524 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -845,6 +845,14 @@ void SIInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
}
}
+ if (AMDGPU::APERTURE_ClassRegClass.contains(DestReg)) {
+ if (SrcReg == AMDGPU::VCC) {
+ BuildMI(MBB, MI, DL, get(AMDGPU::S_MOV_B64), DestReg)
+ .addReg(SrcReg, getKillRegState(KillSrc));
+ return;
+ }
+ }
+
if (RC == &AMDGPU::VGPR_32RegClass) {
assert(AMDGPU::VGPR_32RegClass.contains(SrcReg) ||
AMDGPU::SReg_32RegClass.contains(SrcReg) ||
diff --git a/llvm/test/CodeGen/AMDGPU/sgpr-phys-copy.mir b/llvm/test/CodeGen/AMDGPU/sgpr-phys-copy.mir
index f11fe4aa6e00e..78e8788c7f0f0 100644
--- a/llvm/test/CodeGen/AMDGPU/sgpr-phys-copy.mir
+++ b/llvm/test/CodeGen/AMDGPU/sgpr-phys-copy.mir
@@ -67,6 +67,15 @@ body: |
$vcc = COPY $src_shared_base
...
+---
+name: vcc_to_src_shared_base
+body: |
+ bb.0:
+ ; GFX9-LABEL: name: vcc_to_src_shared_base
+ ; GFX9: $src_shared_base = S_MOV_B64 $vcc
+ $src_shared_base = COPY $vcc
+...
+
---
name: sgpr96_aligned_src_dst
body: |
|
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
ec8bab7 to
080158a
Compare
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.
I don't think s_mov_b64 would allow SRC_SHARED_BASE as destination. It is not one of the categories in sdst.
Then the instruction definitions are wrong, because this should fail the verifier if it's not valid |
|
I think it does fail in the verifier, based on #163244 (comment). |
|
This is readonly register, like any |
|
Section 5.2 of the MI300 programming guide indicates: "[..] 128-255 can only be used as sources." |
|
I ran it through the debugger looking at what happens in verifyInstruction in the same file. Both copies from VCC to SHARED_BASE and from SHARED_BASE to VCC get out at 4971 if (SIInstrInfo::isGenericOpcode(Opcode)) There is no verification done on the src and dst registers if you get out of the function this early. |
|
The comment after that early exit seems relevant: // FIXME: At this point the COPY verify is done only for non-ssa forms. I'll leave this alone for the time being, but please @arsenm let me know if there is any extra verification you think we should be doing. |
That sounds like you're looking at a COPY instruction? MachineVerfier should still fail for an S_MOV_B64 instruction like the one you generate in this patch. |
|
@jayfoad can you please point me to where the verification should happen? |
You would have to run the verifier after you have converted the COPY to S_MOV_B64, so after the ExpandPostRAPseudos (aka postrapseudos) pass. You could run |
|
Thanks, below is what I see. It doesn't report that shared_base is non writable, but a problem with src_shared_base not being a SReg_64 register, which is as good I guess. # After Post-RA pseudo instruction expansion pass bb.0: # End machine code for function vcc_to_src_shared_base. *** Bad machine code: Operand has incorrect register class. ***
*** Bad machine code: Illegal physical register for instruction ***
|
No description provided.