Skip to content

Commit 74cd4de

Browse files
committed
[AMDGPU] Preserve deadness of vcc when shrinking instructions
This doesn't have any effect on codegen now, but it might do in the future if we shrink instructions before post-RA scheduling, which is sensitive to live vs dead defs. Differential Revision: https://reviews.llvm.org/D112305
1 parent 3f00e10 commit 74cd4de

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,10 @@ bool SIShrinkInstructions::runOnMachineFunction(MachineFunction &MF) {
810810
// Copy extra operands not present in the instruction definition.
811811
copyExtraImplicitOps(*Inst32, MF, MI);
812812

813+
// Copy deadness from the old explicit vcc def to the new implicit def.
814+
if (SDst && SDst->isDead())
815+
Inst32->findRegisterDefOperand(VCCReg)->setIsDead();
816+
813817
MI.eraseFromParent();
814818
foldImmediates(*Inst32, TII, MRI);
815819

llvm/test/CodeGen/AMDGPU/shrink-carry.mir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs -start-before si-shrink-instructions -stop-before si-late-branch-lowering -o - %s | FileCheck -check-prefix=GCN %s
22

33
# GCN-LABEL: name: subbrev{{$}}
4-
# GCN: V_SUBBREV_U32_e32 0, undef $vgpr0, implicit-def $vcc, implicit killed $vcc, implicit $exec
4+
# GCN: V_SUBBREV_U32_e32 0, undef $vgpr0, implicit-def dead $vcc, implicit killed $vcc, implicit $exec
55

66
---
77
name: subbrev
@@ -26,7 +26,7 @@ body: |
2626
...
2727

2828
# GCN-LABEL: name: subb{{$}}
29-
# GCN: V_SUBBREV_U32_e32 0, undef $vgpr0, implicit-def $vcc, implicit killed $vcc, implicit $exec
29+
# GCN: V_SUBBREV_U32_e32 0, undef $vgpr0, implicit-def dead $vcc, implicit killed $vcc, implicit $exec
3030

3131
---
3232
name: subb
@@ -51,7 +51,7 @@ body: |
5151
...
5252

5353
# GCN-LABEL: name: addc{{$}}
54-
# GCN: V_ADDC_U32_e32 0, undef $vgpr0, implicit-def $vcc, implicit killed $vcc, implicit $exec
54+
# GCN: V_ADDC_U32_e32 0, undef $vgpr0, implicit-def dead $vcc, implicit killed $vcc, implicit $exec
5555

5656
---
5757
name: addc
@@ -76,7 +76,7 @@ body: |
7676
...
7777

7878
# GCN-LABEL: name: addc2{{$}}
79-
# GCN: V_ADDC_U32_e32 0, undef $vgpr0, implicit-def $vcc, implicit killed $vcc, implicit $exec
79+
# GCN: V_ADDC_U32_e32 0, undef $vgpr0, implicit-def dead $vcc, implicit killed $vcc, implicit $exec
8080

8181
---
8282
name: addc2

0 commit comments

Comments
 (0)