Files
llvm-project/llvm/test/CodeGen/AArch64/machine-cp-backward-uses.mir
Vladimir Radosavljevic 401d123a1f [MCP] Optimize copies when src is used during backward propagation (#111130)
Before this patch, redundant COPY couldn't be removed for the following
case:
```
  $R0 = OP ...
  ... // Read of %R0
  $R1 = COPY killed $R0
```
This patch adds support for tracking the users of the source register
during backward propagation, so that we can remove the redundant COPY in
the above case and optimize it to:
```
  $R1 = OP ...
  ... // Replace all uses of %R0 with $R1
```
2024-10-23 13:37:02 +02:00

59 lines
1.8 KiB
YAML

# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
# RUN: llc -mtriple=aarch64-none-linux-gnu -run-pass machine-cp -verify-machineinstrs -o - %s | FileCheck %s
# Normal case
---
name: test1
body: |
bb.0:
liveins: $w2
; CHECK-LABEL: name: test1
; CHECK: liveins: $w2
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: renamable $w0 = MOVi32imm 5
; CHECK-NEXT: renamable $w3 = ADDWrr renamable $w0, killed renamable $w2
; CHECK-NEXT: RET_ReallyLR implicit killed $w0
renamable $w1 = MOVi32imm 5
renamable $w3 = ADDWrr renamable $w1, killed renamable $w2
renamable $w0 = COPY killed renamable $w1
RET_ReallyLR implicit killed $w0
...
# Not renamable use
---
name: test2
body: |
bb.0:
liveins: $w2
; CHECK-LABEL: name: test2
; CHECK: liveins: $w2
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: renamable $w1 = MOVi32imm 5
; CHECK-NEXT: renamable $w3 = ADDWrr $w1, killed renamable $w2
; CHECK-NEXT: renamable $w0 = COPY killed renamable $w1
; CHECK-NEXT: RET_ReallyLR implicit killed $w0
renamable $w1 = MOVi32imm 5
renamable $w3 = ADDWrr $w1, killed renamable $w2
renamable $w0 = COPY killed renamable $w1
RET_ReallyLR implicit killed $w0
...
# Implicit use
---
name: test3
body: |
bb.0:
liveins: $w2
; CHECK-LABEL: name: test3
; CHECK: liveins: $w2
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: renamable $w1 = MOVi32imm 5
; CHECK-NEXT: renamable $w3 = ADDWrr renamable $w1, killed renamable $w2, implicit $w1
; CHECK-NEXT: renamable $w0 = COPY killed renamable $w1
; CHECK-NEXT: RET_ReallyLR implicit killed $w0
renamable $w1 = MOVi32imm 5
renamable $w3 = ADDWrr renamable $w1, killed renamable $w2, implicit $w1
renamable $w0 = COPY killed renamable $w1
RET_ReallyLR implicit killed $w0
...