-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LiveVariables] Mark use without implicit if defined at instr #119446
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 1 commit
6b852f9
0208eb9
e0cd95a
1fa40b7
ebc5d0c
a44bb8d
7b3266e
a9d1662
0ecabb7
6669df1
5672eae
4ac7fce
7948dfd
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 |
|---|---|---|
|
|
@@ -277,11 +277,22 @@ void LiveVariables::HandlePhysRegUse(Register Reg, MachineInstr &MI) { | |
| continue; | ||
| if (PartDefRegs.count(SubReg)) | ||
| continue; | ||
|
|
||
| // Check if SubReg is defined at LastPartialDef. | ||
| bool IsDefinedHere = false; | ||
| for (int I = 0; I < LastPartialDef->getNumOperands(); ++I) { | ||
| const auto MO = LastPartialDef->getOperand(I); | ||
| if (!MO.isReg() || !MO.isDef()) | ||
| continue; | ||
| if (TRI->isSubRegister(SubReg, MO.getReg())) { | ||
| IsDefinedHere = true; | ||
| break; | ||
| } | ||
| } | ||
| // This part of Reg was defined before the last partial def. It's killed | ||
| // here. | ||
| LastPartialDef->addOperand(MachineOperand::CreateReg(SubReg, | ||
| false/*IsDef*/, | ||
| true/*IsImp*/)); | ||
| LastPartialDef->addOperand( | ||
| MachineOperand::CreateReg(SubReg, IsDefinedHere, true /*IsImp*/)); | ||
|
||
| PhysRegDef[SubReg] = LastPartialDef; | ||
| for (MCPhysReg SS : TRI->subregs(SubReg)) | ||
| Processed.insert(SS); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 | ||
jofrn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # RUN: llc -mtriple=amdgcn --run-pass=livevars -o - %s | FileCheck %s | ||
| --- | ||
| name: sgpr_copy | ||
| tracksRegLiveness: true | ||
| body: | | ||
| bb.0: | ||
| ; CHECK-LABEL: name: sgpr_copy | ||
| ; CHECK: %sval:sreg_32 = S_MOV_B32 0 | ||
| ; CHECK-NEXT: $sgpr0 = COPY %sval | ||
| ; CHECK-NEXT: $sgpr1 = COPY %sval | ||
| ; CHECK-NEXT: $sgpr2 = COPY %sval | ||
| ; CHECK-NEXT: $sgpr3 = COPY killed %sval, implicit-def $sgpr0_sgpr1_sgpr2_sgpr3, implicit $sgpr0, implicit $sgpr1, implicit $sgpr2, implicit $sgpr0_sgpr1, implicit $sgpr0_sgpr1_sgpr2, implicit-def $sgpr2_sgpr3 | ||
| ; CHECK-NEXT: dead $sgpr30_sgpr31 = COPY killed $sgpr0_sgpr1_sgpr2_sgpr3 | ||
|
|
||
| %sval:sreg_32 = S_MOV_B32 0 | ||
|
|
||
| $sgpr0 = COPY %sval | ||
| $sgpr1 = COPY %sval | ||
| $sgpr2 = COPY %sval | ||
| $sgpr3 = COPY %sval | ||
| $sgpr30_sgpr31 = COPY $sgpr0_sgpr1_sgpr2_sgpr3 | ||
|
|
||
| ... | ||
| --- | ||
| name: vgpr_copy | ||
| tracksRegLiveness: true | ||
| body: | | ||
| bb.0: | ||
| ; CHECK-LABEL: name: vgpr_copy | ||
| ; CHECK: %vval:vgpr_32 = V_MOV_B32_e32 0, implicit $exec | ||
| ; CHECK-NEXT: $vgpr0 = COPY %vval | ||
| ; CHECK-NEXT: $vgpr1 = COPY %vval | ||
| ; CHECK-NEXT: $vgpr2 = COPY %vval | ||
| ; CHECK-NEXT: $vgpr3 = COPY killed %vval, implicit-def $vgpr0_vgpr1_vgpr2_vgpr3, implicit $vgpr0, implicit $vgpr1, implicit $vgpr2, implicit $vgpr0_vgpr1, implicit $vgpr0_vgpr1_vgpr2, implicit-def $vgpr1_vgpr2_vgpr3 | ||
| ; CHECK-NEXT: dead [[COPY:%[0-9]+]]:vgpr_32 = COPY killed $vgpr0_vgpr1_vgpr2_vgpr3 | ||
|
|
||
| %vval:vgpr_32 = V_MOV_B32_e32 0, implicit $exec | ||
|
|
||
| $vgpr0 = COPY %vval | ||
| $vgpr1 = COPY %vval | ||
| $vgpr2 = COPY %vval | ||
| $vgpr3 = COPY %vval | ||
| %0:vgpr_32 = COPY $vgpr0_vgpr1_vgpr2_vgpr3 | ||
|
|
||
| ... | ||
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 whole function looks like it could use a rewrite. Is this a re-invention of MachineInstr::modifiesRegister?
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.
The parent function,
LiveVariables::HandlePhysRegUse, will additionally collect definitions ofReg(e.g. fourCOPYinstructions for a use of$sgpr0_$sgpr1_$sgpr2_sgpr3in a subsequent instruction), and mark the last definition with its implicit uses and defs.modifiesRegistercan be used here in place of this loop. It will also mark superregisters though, so will try the tests again...