-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU] Set hasSideEffects=0 for SALU psuedos #134487
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
Conversation
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-backend-amdgpu Author: None (amansharma612) ChangesFixes #128685 Full diff: https://github.com/llvm/llvm-project/pull/134487.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/SIInstructions.td b/llvm/lib/Target/AMDGPU/SIInstructions.td
index 9051db0c01ed1..e78a29e36b358 100644
--- a/llvm/lib/Target/AMDGPU/SIInstructions.td
+++ b/llvm/lib/Target/AMDGPU/SIInstructions.td
@@ -340,19 +340,27 @@ def S_SUB_U64_PSEUDO : SPseudoInstSI <
def S_ADD_CO_PSEUDO : SPseudoInstSI <
(outs SReg_32:$sdst, SSrc_i1:$scc_out), (ins SSrc_b32:$src0, SSrc_b32:$src1, SSrc_i1:$scc_in)
->;
+>{
+ let hasSideEffects = 0;
+}
def S_SUB_CO_PSEUDO : SPseudoInstSI <
(outs SReg_32:$sdst, SSrc_i1:$scc_out), (ins SSrc_b32:$src0, SSrc_b32:$src1, SSrc_i1:$scc_in)
->;
+>{
+ let hasSideEffects = 0;
+}
def S_UADDO_PSEUDO : SPseudoInstSI <
(outs SReg_32:$sdst, SSrc_i1:$scc_out), (ins SSrc_b32:$src0, SSrc_b32:$src1)
->;
+>{
+ let hasSideEffects = 0;
+}
def S_USUBO_PSEUDO : SPseudoInstSI <
(outs SReg_32:$sdst, SSrc_i1:$scc_out), (ins SSrc_b32:$src0, SSrc_b32:$src1)
->;
+>{
+ let hasSideEffects = 0;
+}
let OtherPredicates = [HasShaderCyclesHiLoRegisters] in
def GET_SHADERCYCLESHILO : SPseudoInstSI<
diff --git a/llvm/lib/Target/AMDGPU/SOPInstructions.td b/llvm/lib/Target/AMDGPU/SOPInstructions.td
index 73f4655f735a2..be63bc4a745eb 100644
--- a/llvm/lib/Target/AMDGPU/SOPInstructions.td
+++ b/llvm/lib/Target/AMDGPU/SOPInstructions.td
@@ -665,12 +665,16 @@ let SubtargetPredicate = isGFX12Plus in {
// The higher 32-bits of the inputs contain the sign extension bits.
def S_MUL_I64_I32_PSEUDO : SPseudoInstSI <
(outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b64:$src1)
- >;
+ >{
+ let hasSideEffects = 0;
+ }
// The higher 32-bits of the inputs are zero.
def S_MUL_U64_U32_PSEUDO : SPseudoInstSI <
(outs SReg_64:$sdst), (ins SSrc_b64:$src0, SSrc_b64:$src1)
- >;
+ >{
+ let hasSideEffects = 0;
+ }
} // End SubtargetPredicate = isGFX12Plus
|
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'm curious why no side effects is not the default and this needs to be explicit for these pseudos in particular? Is there any motivating test/example where this impacts scheduling or some other optimization?
Wrong by default is a horrible design mistake LLVM has repeated in far too many places. This is the correct default |
@@ -340,19 +340,27 @@ def S_SUB_U64_PSEUDO : SPseudoInstSI < | |||
|
|||
def S_ADD_CO_PSEUDO : SPseudoInstSI < | |||
(outs SReg_32:$sdst, SSrc_i1:$scc_out), (ins SSrc_b32:$src0, SSrc_b32:$src1, SSrc_i1:$scc_in) | |||
>; | |||
>{ |
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.
Move >{ to previous line
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.
nit: use let hasSideEffects=0 in { .. }
to avoid repetition?
I doubt it, these are a SelectionDAG hack more than anything and expand immediately. It doesn't hurt to correct this though |
Regression test |
Probably just need to run update_llc_test_checks |
Could also do this for S_INVERSE_BALLOT_U32/64 |
9e0202c
to
926a934
Compare
LGTM but could also do this for the inverse ballots |
@arsenm I've added the changes for inverse ballots already |
@@ -231,7 +231,7 @@ def EXIT_STRICT_WQM : SPseudoInstSI <(outs SReg_1:$sdst), (ins SReg_1:$src0)> { | |||
let mayStore = 0; | |||
} | |||
|
|||
let usesCustomInserter = 1 in { | |||
let usesCustomInserter = 1, hasSideEffects = 0 in { |
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.
Update the corresponding // End
comment below.
926a934
to
baddce9
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.
LGTM, thanks.
@amansharma612 Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
Fixes llvm#128685 --------- Co-authored-by: Aman Sharma <[email protected]>
Fixes #128685