Skip to content

SystemZ: Handle copies between gr64 and fp64 #124890

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 1 commit into from
Jan 30, 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
6 changes: 6 additions & 0 deletions llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,12 @@ void SystemZInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
Opcode = SystemZ::VLR;
else if (SystemZ::AR32BitRegClass.contains(DestReg, SrcReg))
Opcode = SystemZ::CPYA;
else if (SystemZ::GR64BitRegClass.contains(DestReg) &&
SystemZ::FP64BitRegClass.contains(SrcReg))
Opcode = SystemZ::LGDR;
else if (SystemZ::FP64BitRegClass.contains(DestReg) &&
SystemZ::GR64BitRegClass.contains(SrcReg))
Opcode = SystemZ::LDGR;
else
llvm_unreachable("Impossible reg-to-reg copy");

Expand Down
48 changes: 48 additions & 0 deletions llvm/test/CodeGen/SystemZ/copy-phys-reg-fp64-to-gr64.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
# RUN: llc -mtriple=s390x-ibm-linux -mcpu=z13 -run-pass=postrapseudos -o - %s | FileCheck %s

---
name: copy_fp64_to_gr64__r1d_to_f3d
tracksRegLiveness: true
body: |
bb.0:
liveins: $r1d
; CHECK-LABEL: name: copy_fp64_to_gr64__r1d_to_f3d
; CHECK: liveins: $r1d
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: $f3d = LDGR $r1d
; CHECK-NEXT: Return implicit $f3d
$f3d = COPY $r1d
Return implicit $f3d
...

---
name: copy_fp64_to_gr64__r1d_to_f3d_undef
tracksRegLiveness: true
body: |
bb.0:
liveins: $r1d
; CHECK-LABEL: name: copy_fp64_to_gr64__r1d_to_f3d_undef
; CHECK: liveins: $r1d
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: $f3d = KILL undef $r1d
; CHECK-NEXT: Return implicit $f3d
$f3d = COPY undef $r1d
Return implicit $f3d
...

---
name: copy_fp64_to_gr64__r1d_to_f3d_killed
tracksRegLiveness: true
body: |
bb.0:
liveins: $r1d
; CHECK-LABEL: name: copy_fp64_to_gr64__r1d_to_f3d_killed
; CHECK: liveins: $r1d
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: $f3d = LDGR killed $r1d
; CHECK-NEXT: Return implicit $f3d
$f3d = COPY killed $r1d
Return implicit $f3d
...

47 changes: 47 additions & 0 deletions llvm/test/CodeGen/SystemZ/copy-phys-reg-gr64-to-fp64.mir
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
# RUN: llc -mtriple=s390x-ibm-linux -mcpu=z13 -run-pass=postrapseudos -o - %s | FileCheck %s
---
name: copy_fp64_to_gr64__f3d_to_r1d
tracksRegLiveness: true
body: |
bb.0:
liveins: $f3d
; CHECK-LABEL: name: copy_fp64_to_gr64__f3d_to_r1d
; CHECK: liveins: $f3d
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: $r1d = LGDR $f3d
; CHECK-NEXT: Return implicit $r1d
$r1d = COPY $f3d
Return implicit $r1d
...

---
name: copy_fp64_to_gr64__f3d_to_r1d_undef
tracksRegLiveness: true
body: |
bb.0:
liveins: $f3d
; CHECK-LABEL: name: copy_fp64_to_gr64__f3d_to_r1d_undef
; CHECK: liveins: $f3d
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: $r1d = KILL undef $f3d
; CHECK-NEXT: Return implicit $r1d
$r1d = COPY undef $f3d
Return implicit $r1d
...

---
name: copy_fp64_to_gr64__f3d_to_r1d_killed
tracksRegLiveness: true
body: |
bb.0:
liveins: $f3d
; CHECK-LABEL: name: copy_fp64_to_gr64__f3d_to_r1d_killed
; CHECK: liveins: $f3d
; CHECK-NEXT: {{ $}}
; CHECK-NEXT: $r1d = LGDR killed $f3d
; CHECK-NEXT: Return implicit $r1d
$r1d = COPY killed $f3d
Return implicit $r1d
...