[PATCH] D148509: [BranchFolder] Skip redundant IMPLICIT_DEFs of subregs
Jay Foad via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 17 03:55:02 PDT 2023
foad updated this revision to Diff 514156.
foad added a comment.
Use any_of. Rename test.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D148509/new/
https://reviews.llvm.org/D148509
Files:
llvm/lib/CodeGen/BranchFolding.cpp
llvm/test/CodeGen/AMDGPU/branch-folding-implicit-def-subreg.ll
Index: llvm/test/CodeGen/AMDGPU/branch-folding-implicit-def-subreg.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/branch-folding-implicit-def-subreg.ll
+++ llvm/test/CodeGen/AMDGPU/branch-folding-implicit-def-subreg.ll
@@ -37,20 +37,10 @@
; GFX90A-NEXT: renamable $sgpr34_sgpr35 = S_MOV_B64 0
; GFX90A-NEXT: renamable $vcc = S_AND_B64 $exec, renamable $sgpr30_sgpr31, implicit-def dead $scc
; GFX90A-NEXT: $vgpr24 = IMPLICIT_DEF
- ; GFX90A-NEXT: $vgpr24_lo16 = IMPLICIT_DEF
- ; GFX90A-NEXT: $vgpr24_hi16 = IMPLICIT_DEF
; GFX90A-NEXT: $agpr0 = IMPLICIT_DEF
- ; GFX90A-NEXT: $agpr0_lo16 = IMPLICIT_DEF
- ; GFX90A-NEXT: $agpr0_hi16 = IMPLICIT_DEF
- ; GFX90A-NEXT: $vgpr26_lo16 = IMPLICIT_DEF
- ; GFX90A-NEXT: $vgpr26_hi16 = IMPLICIT_DEF
; GFX90A-NEXT: $vgpr26 = IMPLICIT_DEF
; GFX90A-NEXT: $vgpr20 = IMPLICIT_DEF
- ; GFX90A-NEXT: $vgpr20_lo16 = IMPLICIT_DEF
- ; GFX90A-NEXT: $vgpr20_hi16 = IMPLICIT_DEF
; GFX90A-NEXT: $vgpr22 = IMPLICIT_DEF
- ; GFX90A-NEXT: $vgpr22_lo16 = IMPLICIT_DEF
- ; GFX90A-NEXT: $vgpr22_hi16 = IMPLICIT_DEF
; GFX90A-NEXT: S_CBRANCH_VCCNZ %bb.58, implicit $vcc
; GFX90A-NEXT: {{ $}}
; GFX90A-NEXT: bb.2:
@@ -583,11 +573,7 @@
; GFX90A-NEXT: renamable $vgpr63, dead renamable $vcc = V_ADDC_U32_e64 0, $vgpr41, killed $vcc, 0, implicit $exec
; GFX90A-NEXT: renamable $vcc = S_AND_B64 $exec, renamable $sgpr48_sgpr49, implicit-def dead $scc
; GFX90A-NEXT: $agpr0 = IMPLICIT_DEF
- ; GFX90A-NEXT: $agpr0_lo16 = IMPLICIT_DEF
- ; GFX90A-NEXT: $agpr0_hi16 = IMPLICIT_DEF
; GFX90A-NEXT: $vgpr14 = IMPLICIT_DEF
- ; GFX90A-NEXT: $vgpr14_lo16 = IMPLICIT_DEF
- ; GFX90A-NEXT: $vgpr14_hi16 = IMPLICIT_DEF
; GFX90A-NEXT: S_CBRANCH_VCCNZ %bb.48, implicit $vcc
; GFX90A-NEXT: {{ $}}
; GFX90A-NEXT: bb.44:
Index: llvm/lib/CodeGen/BranchFolding.cpp
===================================================================
--- llvm/lib/CodeGen/BranchFolding.cpp
+++ llvm/lib/CodeGen/BranchFolding.cpp
@@ -860,6 +860,14 @@
for (Register Reg : NewLiveIns) {
if (!LiveRegs.available(*MRI, Reg))
continue;
+
+ // Skip the register if we are about to add one of its super registers.
+ // TODO: Common this up with the same logic in addLineIns().
+ if (any_of(TRI->superregs(Reg), [&](MCPhysReg SReg) {
+ return NewLiveIns.contains(SReg) && !MRI->isReserved(SReg);
+ }))
+ continue;
+
DebugLoc DL;
BuildMI(*Pred, InsertBefore, DL, TII->get(TargetOpcode::IMPLICIT_DEF),
Reg);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148509.514156.patch
Type: text/x-patch
Size: 2653 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230417/fa283d8a/attachment.bin>
More information about the llvm-commits
mailing list