[llvm] [AMDGPU] Machine-CP is deleting incorrect copy instr. (PR #114773)

Pravin Jagtap via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 4 03:05:01 PST 2024


https://github.com/pravinjagtap created https://github.com/llvm/llvm-project/pull/114773

During AGPR tuple SPILLing, AMDGPU backend marks
the tuple as implicit-def in the first spill
instruction. It clobbers the register and the
machine-cp thinks its def i.e. copy is deletable
which I think is incorrect. Seeking help
to understand whether following copy is
deletable here ? (given the fact that compiler
decided to mark it implicit-def for preserving the liveness)

renamable $agpr1 = COPY renamable $agpr3, implicit $exec

>From 8f451842cbd687fa746922848fd792d96970455e Mon Sep 17 00:00:00 2001
From: Pravin Jagtap <Pravin.Jagtap at amd.com>
Date: Mon, 4 Nov 2024 16:28:36 +0530
Subject: [PATCH] [AMDGPU] Machine-CP is deleting incorrect copy instr.

During AGPR tuple SPILLing, AMDGPU backend marks
the tuple as implicit-def in the first spill
instruction. It clobbers the register and the
machine-cp thinks its def i.e. copy is deletable
which I think is incorrect. Seeking help
to understand whether following copy is
deletable here ? (given the fact that compiler
decided to mark it implicit-def for preserving the
liveness)

renamable $agpr1 = COPY renamable $agpr3, implicit $exec
---
 .../AMDGPU/incorrect-copy-deletion.mir        | 24 +++++++++++++++++++
 1 file changed, 24 insertions(+)
 create mode 100644 llvm/test/CodeGen/AMDGPU/incorrect-copy-deletion.mir

diff --git a/llvm/test/CodeGen/AMDGPU/incorrect-copy-deletion.mir b/llvm/test/CodeGen/AMDGPU/incorrect-copy-deletion.mir
new file mode 100644
index 00000000000000..a4ec8ca825aee4
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/incorrect-copy-deletion.mir
@@ -0,0 +1,24 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -mtriple=amdgcn -mcpu=gfx908 %s -o - -run-pass machine-cp -verify-machineinstrs | FileCheck -check-prefix=GFX908 %s
+
+---
+name:  foo
+tracksRegLiveness: true
+body: |
+  bb.0:
+    successors:
+    liveins: $vgpr0, $agpr3
+
+    ; GFX908-LABEL: name: foo
+    ; GFX908: liveins: $vgpr0, $agpr3
+    ; GFX908-NEXT: {{  $}}
+    ; GFX908-NEXT: renamable $agpr0 = COPY renamable $vgpr0, implicit $exec
+    ; GFX908-NEXT: $vgpr254 = V_ACCVGPR_READ_B32_e64 $agpr0, implicit $exec, implicit-def $agpr0_agpr1
+    ; GFX908-NEXT: $vgpr255 = V_ACCVGPR_READ_B32_e64 $agpr1, implicit $exec
+    ; GFX908-NEXT: S_ENDPGM 0
+    renamable $agpr0 = COPY renamable $vgpr0, implicit $exec
+    renamable $agpr1 = COPY renamable $agpr3, implicit $exec
+    $vgpr254 = V_ACCVGPR_READ_B32_e64 $agpr0, implicit $exec, implicit-def $agpr0_agpr1
+    $vgpr255 = V_ACCVGPR_READ_B32_e64 $agpr1, implicit $exec
+    S_ENDPGM 0
+...



More information about the llvm-commits mailing list