-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[AMDGPU] Cleanup hasUnwantedEffectsWhenEXECEmpty function #70206
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] Cleanup hasUnwantedEffectsWhenEXECEmpty function #70206
Conversation
The readlane & writelane instructions don't really depend on the the EXEC mask and they should return false from here.
@llvm/pr-subscribers-backend-amdgpu Author: Christudasan Devadasan (cdevadas) ChangesThe readlane & writelane instructions don't really depend on the the EXEC mask and they should return false from here. Full diff: https://github.com/llvm/llvm-project/pull/70206.diff 2 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
index 4ff7b462f0f3295..827c2c156638468 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.cpp
@@ -3906,8 +3906,7 @@ bool SIInstrInfo::hasUnwantedEffectsWhenEXECEmpty(const MachineInstr &MI) const
//
// However, executing them with EXEC = 0 causes them to operate on undefined
// data, which we avoid by returning true here.
- if (Opcode == AMDGPU::V_READFIRSTLANE_B32 ||
- Opcode == AMDGPU::V_READLANE_B32 || Opcode == AMDGPU::V_WRITELANE_B32)
+ if (Opcode == AMDGPU::V_READFIRSTLANE_B32)
return true;
return false;
diff --git a/llvm/test/CodeGen/AMDGPU/remove-short-exec-branches-special-instructions.mir b/llvm/test/CodeGen/AMDGPU/remove-short-exec-branches-special-instructions.mir
index fe4aa6a9aea68cb..8f3f70ea6287ee9 100644
--- a/llvm/test/CodeGen/AMDGPU/remove-short-exec-branches-special-instructions.mir
+++ b/llvm/test/CodeGen/AMDGPU/remove-short-exec-branches-special-instructions.mir
@@ -130,13 +130,12 @@ body: |
---
-name: need_skip_writelane_b32
+name: dont_skip_writelane_b32
body: |
- ; CHECK-LABEL: name: need_skip_writelane_b32
+ ; CHECK-LABEL: name: dont_skip_writelane_b32
; CHECK: bb.0:
- ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
+ ; CHECK-NEXT: successors: %bb.1(0x40000000)
; CHECK-NEXT: {{ $}}
- ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.2, implicit $exec
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1:
; CHECK-NEXT: successors: %bb.2(0x80000000)
@@ -160,13 +159,12 @@ body: |
...
---
-name: need_skip_readlane_b32
+name: dont_skip_readlane_b32
body: |
- ; CHECK-LABEL: name: need_skip_readlane_b32
+ ; CHECK-LABEL: name: dont_skip_readlane_b32
; CHECK: bb.0:
- ; CHECK-NEXT: successors: %bb.1(0x40000000), %bb.2(0x40000000)
+ ; CHECK-NEXT: successors: %bb.1(0x40000000)
; CHECK-NEXT: {{ $}}
- ; CHECK-NEXT: S_CBRANCH_EXECZ %bb.2, implicit $exec
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: bb.1:
; CHECK-NEXT: successors: %bb.2(0x80000000)
|
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 assuming this doesn't break anything
I don't think the change is ok. The function |
Out of caution, I think this should be reverted. The lack of test coverage in the code base is probably part of the problem why this looks like an OK change. The pre-existing comment is misleading, and that might have not helped the confusion.
This suggests maybe we can remove them, but then says they are undefined.
Where the result of v_cmp is effected by EXEC=0, but v_writelane still uses the value. Taking a step back, the problem exists because we peephole remove |
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.
Ok
@jonesk7734 are you a bot? |
Patch reverted with 16fbc45. |
No I am not a bot.
…On Thu, Oct 26, 2023 at 7:53 AM Christudasan Devadasan < ***@***.***> wrote:
Patch reverted with 16fbc45
<16fbc45>
.
—
Reply to this email directly, view it on GitHub
<#70206 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BBYSMOFCJ7ITD6UGGFNCOADYBJFKRAVCNFSM6AAAAAA6PKRCCGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBQHE3DGMJSGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
The readlane & writelane instructions don't really depend on the the EXEC mask and they should return false from here.