Skip to content

Commit e4b4a93

Browse files
authored
[MCP] Disable BackwardCopyPropagateBlock for copies with implicit registers. (#137687)
If there's an implicit-def of a super register, the propagation must preserve this implicit-def. Knowing how and when to do this may require target specific knowledge so just disable it for now. Prior to 2def1c4, we checked that the copy had explicit 2 operands when that was removed we started allowing implicit operands through. This patch adds a check for implicit operands, but still allows extra explicit operands which was the goal of 2def1c4. Fixes #131478.
1 parent a25d38d commit e4b4a93

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

llvm/lib/CodeGen/MachineCopyPropagation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,7 @@ void MachineCopyPropagation::BackwardCopyPropagateBlock(
12061206
// Ignore non-trivial COPYs.
12071207
std::optional<DestSourcePair> CopyOperands =
12081208
isCopyInstr(MI, *TII, UseCopyInstr);
1209-
if (CopyOperands) {
1209+
if (CopyOperands && MI.getNumImplicitOperands() == 0) {
12101210
Register DefReg = CopyOperands->Destination->getReg();
12111211
Register SrcReg = CopyOperands->Source->getReg();
12121212

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2+
# RUN: llc %s -mtriple=s390x-unknown-linux-gnu -run-pass=machine-cp -verify-machineinstrs -o - | FileCheck %s
3+
4+
---
5+
name: t
6+
tracksRegLiveness: true
7+
noPhis: true
8+
isSSA: false
9+
noVRegs: true
10+
hasFakeUses: false
11+
tracksDebugUserValues: true
12+
body: |
13+
bb.0:
14+
; CHECK-LABEL: name: t
15+
; CHECK: renamable $r14d = LLILL 0
16+
; CHECK-NEXT: renamable $r12d = COPY killed renamable $r14d, implicit-def $r12q
17+
; CHECK-NEXT: Return implicit $r12q
18+
renamable $r14d = LLILL 0
19+
renamable $r12d = COPY killed renamable $r14d, implicit-def $r12q
20+
Return implicit $r12q
21+
...

0 commit comments

Comments
 (0)