Skip to content

[MCP] Disable BackwardCopyPropagateBlock for copies with implicit registers. #137687

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

Merged
merged 2 commits into from
May 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MachineCopyPropagation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,7 +1200,7 @@ void MachineCopyPropagation::BackwardCopyPropagateBlock(
// Ignore non-trivial COPYs.
std::optional<DestSourcePair> CopyOperands =
isCopyInstr(MI, *TII, UseCopyInstr);
if (CopyOperands) {
if (CopyOperands && MI.getNumImplicitOperands() == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought isCopyInstr was already filtering out these hard cases

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it does in the target instruction implementations, not the base copy handling

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well just not use isCopyInstr, you're probably filtering out cases the target code decided are OK

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For RISC-V, we want to support the canonical copy instruction that appears after ExpandPostRAPseudos, "ADDI rd, rs, 0". What are you suggesting we use here instead of isCopyInstr?

Register DefReg = CopyOperands->Destination->getReg();
Register SrcReg = CopyOperands->Source->getReg();

Expand Down
21 changes: 21 additions & 0 deletions llvm/test/CodeGen/SystemZ/pr137687.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
# RUN: llc %s -mtriple=s390x-unknown-linux-gnu -run-pass=machine-cp -verify-machineinstrs -o - | FileCheck %s

---
name: t
tracksRegLiveness: true
noPhis: true
isSSA: false
noVRegs: true
hasFakeUses: false
tracksDebugUserValues: true
body: |
bb.0:
; CHECK-LABEL: name: t
; CHECK: renamable $r14d = LLILL 0
; CHECK-NEXT: renamable $r12d = COPY killed renamable $r14d, implicit-def $r12q
; CHECK-NEXT: Return implicit $r12q
renamable $r14d = LLILL 0
renamable $r12d = COPY killed renamable $r14d, implicit-def $r12q
Return implicit $r12q
...