-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AMDGPU] Fix register class constraints for si-fold-operands pass when folding immediate into copies #131387
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] Fix register class constraints for si-fold-operands pass when folding immediate into copies #131387
Changes from 4 commits
e2e886d
26a3099
547d52f
e655bd6
ec4ad28
a73c5ee
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 |
|---|---|---|
|
|
@@ -202,52 +202,70 @@ body: | | |
|
|
||
| ... | ||
|
|
||
| # FIXME: Register class restrictions of av register not respected, | ||
| # issue 130020 | ||
|
|
||
| # --- | ||
| # name: s_mov_b32_inlineimm_copy_s_to_av_32 | ||
| # tracksRegLiveness: true | ||
| # body: | | ||
| # bb.0: | ||
| # %0:sreg_32 = S_MOV_B32 32 | ||
| # %1:av_32 = COPY %0 | ||
| # $agpr0 = COPY %1 | ||
| # S_ENDPGM 0 | ||
|
|
||
| # ... | ||
|
|
||
| # --- | ||
| # name: v_mov_b32_inlineimm_copy_v_to_av_32 | ||
| # tracksRegLiveness: true | ||
| # body: | | ||
| # bb.0: | ||
| # %0:vgpr_32 = V_MOV_B32_e32 32, implicit $exec | ||
| # %1:av_32 = COPY %0 | ||
| # $agpr0 = COPY %1 | ||
| # S_ENDPGM 0 | ||
| # ... | ||
|
|
||
| # --- | ||
| # name: s_mov_b32_imm_literal_copy_s_to_av_32 | ||
| # tracksRegLiveness: true | ||
| # body: | | ||
| # bb.0: | ||
| # %0:sreg_32 = S_MOV_B32 999 | ||
| # %1:av_32 = COPY %0 | ||
| # $agpr0 = COPY %1 | ||
| # S_ENDPGM 0 | ||
|
|
||
| # ... | ||
|
|
||
| # --- | ||
| # name: v_mov_b32_imm_literal_copy_v_to_av_32 | ||
| # tracksRegLiveness: true | ||
| # body: | | ||
| # bb.0: | ||
| # %0:vgpr_32 = V_MOV_B32_e32 999, implicit $exec | ||
| # %1:av_32 = COPY %0 | ||
| # $agpr0 = COPY %1 | ||
| # S_ENDPGM 0 | ||
|
|
||
| # ... | ||
| --- | ||
| name: s_mov_b32_inlineimm_copy_s_to_av_32 | ||
|
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. New tests need checks for the expected output. Maybe convert the while file to use update_mir_test_checks?
Contributor
Author
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. I have pushed the updated changes. Could you please review?
Contributor
Author
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. Ping |
||
| tracksRegLiveness: true | ||
| body: | | ||
| bb.0: | ||
| ; GCN-LABEL: name: s_mov_b32_inlineimm_copy_s_to_av_32 | ||
| ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 32 | ||
| ; GCN-NEXT: [[COPY:%[0-9]+]]:av_32 = COPY [[S_MOV_B32_]] | ||
| ; GCN-NEXT: $agpr0 = COPY [[COPY]] | ||
| ; GCN-NEXT: S_ENDPGM 0 | ||
| %0:sreg_32 = S_MOV_B32 32 | ||
| %1:av_32 = COPY %0 | ||
| $agpr0 = COPY %1 | ||
| S_ENDPGM 0 | ||
|
|
||
| ... | ||
|
|
||
| --- | ||
| name: v_mov_b32_inlineimm_copy_v_to_av_32 | ||
| tracksRegLiveness: true | ||
| body: | | ||
| bb.0: | ||
| ; GCN-LABEL: name: v_mov_b32_inlineimm_copy_v_to_av_32 | ||
| ; GCN: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 32, implicit $exec | ||
| ; GCN-NEXT: [[COPY:%[0-9]+]]:av_32 = COPY [[V_MOV_B32_e32_]] | ||
| ; GCN-NEXT: $agpr0 = COPY [[COPY]] | ||
| ; GCN-NEXT: S_ENDPGM 0 | ||
| %0:vgpr_32 = V_MOV_B32_e32 32, implicit $exec | ||
| %1:av_32 = COPY %0 | ||
| $agpr0 = COPY %1 | ||
| S_ENDPGM 0 | ||
|
|
||
| ... | ||
|
|
||
| --- | ||
| name: s_mov_b32_imm_literal_copy_s_to_av_32 | ||
| tracksRegLiveness: true | ||
| body: | | ||
| bb.0: | ||
| ; GCN-LABEL: name: s_mov_b32_imm_literal_copy_s_to_av_32 | ||
| ; GCN: [[S_MOV_B32_:%[0-9]+]]:sreg_32 = S_MOV_B32 999 | ||
| ; GCN-NEXT: [[COPY:%[0-9]+]]:av_32 = COPY [[S_MOV_B32_]] | ||
| ; GCN-NEXT: $agpr0 = COPY [[COPY]] | ||
| ; GCN-NEXT: S_ENDPGM 0 | ||
| %0:sreg_32 = S_MOV_B32 999 | ||
| %1:av_32 = COPY %0 | ||
| $agpr0 = COPY %1 | ||
| S_ENDPGM 0 | ||
|
|
||
| ... | ||
|
|
||
| --- | ||
| name: v_mov_b32_imm_literal_copy_v_to_av_32 | ||
| tracksRegLiveness: true | ||
| body: | | ||
| bb.0: | ||
| ; GCN-LABEL: name: v_mov_b32_imm_literal_copy_v_to_av_32 | ||
| ; GCN: [[V_MOV_B32_e32_:%[0-9]+]]:vgpr_32 = V_MOV_B32_e32 999, implicit $exec | ||
| ; GCN-NEXT: [[COPY:%[0-9]+]]:av_32 = COPY [[V_MOV_B32_e32_]] | ||
| ; GCN-NEXT: $agpr0 = COPY [[COPY]] | ||
| ; GCN-NEXT: S_ENDPGM 0 | ||
| %0:vgpr_32 = V_MOV_B32_e32 999, implicit $exec | ||
| %1:av_32 = COPY %0 | ||
| $agpr0 = COPY %1 | ||
| S_ENDPGM 0 | ||
|
|
||
| ... | ||
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.
hasSuperClassEq should be redundant with finding the common class
Uh oh!
There was an error while loading. Please reload this page.
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 think hasSuperClassEq is not redundant with finding common subclass. Consider this basic block where the copy operation is illegal:
In this example:
DestRC is AV_32
ResRC is VGPR_32
CommonRC is VGPR_32
If we only check for CommonRC, the check would allow folding in this case since CommonRC exists (VGPR_32). However, folding here is illegal. And I think we need the condition
if (!DestRC->hasSuperClassEq(CommonRC)) return;.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.
Why do you need CommonRC? Isn't the whole check equivalent to
DestRC->hasSuperClassEq(ResRC)?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.
The code as you have written it is weird, because CommonRC is by construction a subclass of DestRC, and then you are checking that it is a superclass of DestRC. These can only both be true if CommonRC is DestRC.
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.
They should be equivalent check. I am reverting to the previous use of DestRC->hasSuperClassEq(ResRC). @arsenm please let me know if I am missing something.