Skip to content

Commit e83489a

Browse files
author
Baoshan Pang
committed
remove 'movt' if there is no user of it
1 parent a5a6ae1 commit e83489a

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,7 @@ MachineInstr *SIShrinkInstructions::matchSwap(MachineInstr &MovT) const {
797797
dropInstructionKeepingImpDefs(*MovY);
798798
MachineInstr *Next = &*std::next(MovT.getIterator());
799799

800-
if (T.isVirtual() && MRI->use_nodbg_empty(T)) {
800+
if (MRI->use_nodbg_empty(T)) {
801801
dropInstructionKeepingImpDefs(MovT);
802802
} else {
803803
Xop.setIsKill(false);

llvm/test/CodeGen/AMDGPU/v_swap_b32.mir

+1-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# RUN: llc -simplify-mir -mtriple=amdgcn -mcpu=gfx900 -run-pass=si-shrink-instructions -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s
2-
# RUN: llc -simplify-mir -mtriple=amdgcn -mcpu=gfx900 -passes=si-shrink-instructions -verify-machineinstrs %s -o - | FileCheck -check-prefix=GCN %s
32

43
# GCN-LABEL: name: swap_phys_condensed
54
# GCN: bb.0:
65
# GCN-NEXT: liveins:
76
# GCN-NEXT: {{^[ ]*$}}
8-
# GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
97
# GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
108
# GCN-NEXT: S_SETPC_B64_return
119
---
@@ -24,7 +22,6 @@ body: |
2422
# GCN: bb.0:
2523
# GCN-NEXT: liveins:
2624
# GCN-NEXT: {{^[ ]*$}}
27-
# GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
2825
# GCN-NEXT: $vgpr3 = V_MOV_B32_e32 killed $vgpr4, implicit $exec
2926
# GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
3027
# GCN-NEXT: $vgpr5 = V_MOV_B32_e32 killed $vgpr6, implicit $exec
@@ -47,7 +44,6 @@ body: |
4744
# GCN: bb.0:
4845
# GCN-NEXT: liveins:
4946
# GCN-NEXT: {{^[ ]*$}}
50-
# GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
5147
# GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
5248
# GCN-NEXT: S_SETPC_B64_return
5349
---
@@ -66,7 +62,6 @@ body: |
6662
# GCN: bb.0:
6763
# GCN-NEXT: liveins:
6864
# GCN-NEXT: {{^[ ]*$}}
69-
# GCN-NEXT: $vgpr2 = V_MOV_B32_e32 $vgpr0, implicit $exec
7065
# GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
7166
# GCN-NEXT: S_SETPC_B64_return
7267
---
@@ -85,7 +80,6 @@ body: |
8580
# GCN: bb.0:
8681
# GCN-NEXT: liveins:
8782
# GCN-NEXT: {{^[ ]*$}}
88-
# GCN-NEXT: $vgpr4_vgpr5 = COPY $vgpr0_vgpr1
8983
# GCN-NEXT: $vgpr0, $vgpr2 = V_SWAP_B32 $vgpr2, $vgpr0, implicit $exec
9084
# GCN-NEXT: $vgpr1, $vgpr3 = V_SWAP_B32 $vgpr3, $vgpr1, implicit $exec
9185
---
@@ -936,8 +930,7 @@ body: |
936930
...
937931

938932
# GCN-LABEL: implicit_ops_mov_t_swap_b32
939-
# GCN: $vgpr3 = V_MOV_B32_e32 $vgpr0, implicit $exec, implicit $vgpr2, implicit killed $vgpr1_vgpr2, implicit-def $vgpr1
940-
# GCN-NEXT: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
933+
# GCN: $vgpr0, $vgpr1 = V_SWAP_B32 $vgpr1, $vgpr0, implicit $exec
941934

942935
---
943936
name: implicit_ops_mov_t_swap_b32

0 commit comments

Comments
 (0)