[llvm] e4b4a93 - [MCP] Disable BackwardCopyPropagateBlock for copies with implicit registers. (#137687)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 8 16:27:11 PDT 2025
Author: Craig Topper
Date: 2025-05-08T16:27:08-07:00
New Revision: e4b4a939f8852b2d5aab0d5b999890c7ef85be18
URL: https://github.com/llvm/llvm-project/commit/e4b4a939f8852b2d5aab0d5b999890c7ef85be18
DIFF: https://github.com/llvm/llvm-project/commit/e4b4a939f8852b2d5aab0d5b999890c7ef85be18.diff
LOG: [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.
Added:
llvm/test/CodeGen/SystemZ/pr137687.mir
Modified:
llvm/lib/CodeGen/MachineCopyPropagation.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MachineCopyPropagation.cpp b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
index 224588b9d52ed..6eab87c1292e0 100644
--- a/llvm/lib/CodeGen/MachineCopyPropagation.cpp
+++ b/llvm/lib/CodeGen/MachineCopyPropagation.cpp
@@ -1206,7 +1206,7 @@ void MachineCopyPropagation::BackwardCopyPropagateBlock(
// Ignore non-trivial COPYs.
std::optional<DestSourcePair> CopyOperands =
isCopyInstr(MI, *TII, UseCopyInstr);
- if (CopyOperands) {
+ if (CopyOperands && MI.getNumImplicitOperands() == 0) {
Register DefReg = CopyOperands->Destination->getReg();
Register SrcReg = CopyOperands->Source->getReg();
diff --git a/llvm/test/CodeGen/SystemZ/pr137687.mir b/llvm/test/CodeGen/SystemZ/pr137687.mir
new file mode 100644
index 0000000000000..66038f9dce22f
--- /dev/null
+++ b/llvm/test/CodeGen/SystemZ/pr137687.mir
@@ -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
+...
More information about the llvm-commits
mailing list