Skip to content

Commit 1cbfac0

Browse files
authored
SystemZ: Handle copies between gr64 and fp64 (#124890)
I'm guessing based on tablegen definitions. I also don't really understand how this could have been missing. This defends against regressions in a future peephole-opt patch.
1 parent 6017480 commit 1cbfac0

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,12 @@ void SystemZInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
983983
Opcode = SystemZ::VLR;
984984
else if (SystemZ::AR32BitRegClass.contains(DestReg, SrcReg))
985985
Opcode = SystemZ::CPYA;
986+
else if (SystemZ::GR64BitRegClass.contains(DestReg) &&
987+
SystemZ::FP64BitRegClass.contains(SrcReg))
988+
Opcode = SystemZ::LGDR;
989+
else if (SystemZ::FP64BitRegClass.contains(DestReg) &&
990+
SystemZ::GR64BitRegClass.contains(SrcReg))
991+
Opcode = SystemZ::LDGR;
986992
else
987993
llvm_unreachable("Impossible reg-to-reg copy");
988994

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
2+
# RUN: llc -mtriple=s390x-ibm-linux -mcpu=z13 -run-pass=postrapseudos -o - %s | FileCheck %s
3+
4+
---
5+
name: copy_fp64_to_gr64__r1d_to_f3d
6+
tracksRegLiveness: true
7+
body: |
8+
bb.0:
9+
liveins: $r1d
10+
; CHECK-LABEL: name: copy_fp64_to_gr64__r1d_to_f3d
11+
; CHECK: liveins: $r1d
12+
; CHECK-NEXT: {{ $}}
13+
; CHECK-NEXT: $f3d = LDGR $r1d
14+
; CHECK-NEXT: Return implicit $f3d
15+
$f3d = COPY $r1d
16+
Return implicit $f3d
17+
...
18+
19+
---
20+
name: copy_fp64_to_gr64__r1d_to_f3d_undef
21+
tracksRegLiveness: true
22+
body: |
23+
bb.0:
24+
liveins: $r1d
25+
; CHECK-LABEL: name: copy_fp64_to_gr64__r1d_to_f3d_undef
26+
; CHECK: liveins: $r1d
27+
; CHECK-NEXT: {{ $}}
28+
; CHECK-NEXT: $f3d = KILL undef $r1d
29+
; CHECK-NEXT: Return implicit $f3d
30+
$f3d = COPY undef $r1d
31+
Return implicit $f3d
32+
...
33+
34+
---
35+
name: copy_fp64_to_gr64__r1d_to_f3d_killed
36+
tracksRegLiveness: true
37+
body: |
38+
bb.0:
39+
liveins: $r1d
40+
; CHECK-LABEL: name: copy_fp64_to_gr64__r1d_to_f3d_killed
41+
; CHECK: liveins: $r1d
42+
; CHECK-NEXT: {{ $}}
43+
; CHECK-NEXT: $f3d = LDGR killed $r1d
44+
; CHECK-NEXT: Return implicit $f3d
45+
$f3d = COPY killed $r1d
46+
Return implicit $f3d
47+
...
48+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
2+
# RUN: llc -mtriple=s390x-ibm-linux -mcpu=z13 -run-pass=postrapseudos -o - %s | FileCheck %s
3+
---
4+
name: copy_fp64_to_gr64__f3d_to_r1d
5+
tracksRegLiveness: true
6+
body: |
7+
bb.0:
8+
liveins: $f3d
9+
; CHECK-LABEL: name: copy_fp64_to_gr64__f3d_to_r1d
10+
; CHECK: liveins: $f3d
11+
; CHECK-NEXT: {{ $}}
12+
; CHECK-NEXT: $r1d = LGDR $f3d
13+
; CHECK-NEXT: Return implicit $r1d
14+
$r1d = COPY $f3d
15+
Return implicit $r1d
16+
...
17+
18+
---
19+
name: copy_fp64_to_gr64__f3d_to_r1d_undef
20+
tracksRegLiveness: true
21+
body: |
22+
bb.0:
23+
liveins: $f3d
24+
; CHECK-LABEL: name: copy_fp64_to_gr64__f3d_to_r1d_undef
25+
; CHECK: liveins: $f3d
26+
; CHECK-NEXT: {{ $}}
27+
; CHECK-NEXT: $r1d = KILL undef $f3d
28+
; CHECK-NEXT: Return implicit $r1d
29+
$r1d = COPY undef $f3d
30+
Return implicit $r1d
31+
...
32+
33+
---
34+
name: copy_fp64_to_gr64__f3d_to_r1d_killed
35+
tracksRegLiveness: true
36+
body: |
37+
bb.0:
38+
liveins: $f3d
39+
; CHECK-LABEL: name: copy_fp64_to_gr64__f3d_to_r1d_killed
40+
; CHECK: liveins: $f3d
41+
; CHECK-NEXT: {{ $}}
42+
; CHECK-NEXT: $r1d = LGDR killed $f3d
43+
; CHECK-NEXT: Return implicit $r1d
44+
$r1d = COPY killed $f3d
45+
Return implicit $r1d
46+
...
47+

0 commit comments

Comments
 (0)