Skip to content

Commit 470c74f

Browse files
author
Jessica Paquette
committed
[AArch64][GlobalISel] Add regbankselect support for G_LROUND
Destination is always a GPR, since the result is always an integer. Source is always a FPR, since the source is always floating point. Differential Revision: https://reviews.llvm.org/D108419
1 parent 9ae9dd3 commit 470c74f

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,7 @@ bool AArch64RegisterBankInfo::onlyUsesFP(const MachineInstr &MI,
531531
case TargetOpcode::G_FPTOSI:
532532
case TargetOpcode::G_FPTOUI:
533533
case TargetOpcode::G_FCMP:
534+
case TargetOpcode::G_LROUND:
534535
return true;
535536
default:
536537
break;
@@ -959,6 +960,11 @@ AArch64RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
959960
}
960961
break;
961962
}
963+
case TargetOpcode::G_LROUND: {
964+
// Source is always floating point and destination is always integer.
965+
OpRegBankIdx = {PMI_FirstGPR, PMI_FirstFPR};
966+
break;
967+
}
962968
}
963969

964970
// Finally construct the computed mapping.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2+
# RUN: llc -mtriple=aarch64 -run-pass=regbankselect -verify-machineinstrs %s -o - | FileCheck %s
3+
4+
...
5+
---
6+
name: no_cross_bank_copies_needed
7+
legalized: true
8+
regBankSelected: false
9+
tracksRegLiveness: true
10+
body: |
11+
bb.0:
12+
liveins: $d0
13+
; CHECK-LABEL: name: no_cross_bank_copies_needed
14+
; CHECK: liveins: $d0
15+
; CHECK: %fpr:fpr(s64) = COPY $d0
16+
; CHECK: %lround:gpr(s64) = G_LROUND %fpr(s64)
17+
; CHECK: $d0 = COPY %lround(s64)
18+
; CHECK: RET_ReallyLR implicit $s0
19+
%fpr:_(s64) = COPY $d0
20+
%lround:_(s64) = G_LROUND %fpr
21+
$d0 = COPY %lround:_(s64)
22+
RET_ReallyLR implicit $s0
23+
...
24+
---
25+
name: source_needs_copy
26+
legalized: true
27+
regBankSelected: false
28+
tracksRegLiveness: true
29+
body: |
30+
bb.0:
31+
liveins: $x0
32+
; CHECK-LABEL: name: source_needs_copy
33+
; CHECK: liveins: $x0
34+
; CHECK: %gpr:gpr(s64) = COPY $x0
35+
; CHECK: [[COPY:%[0-9]+]]:fpr(s64) = COPY %gpr(s64)
36+
; CHECK: %lround:gpr(s64) = G_LROUND [[COPY]](s64)
37+
; CHECK: $d0 = COPY %lround(s64)
38+
; CHECK: RET_ReallyLR implicit $s0
39+
%gpr:_(s64) = COPY $x0
40+
%lround:_(s64) = G_LROUND %gpr
41+
$d0 = COPY %lround:_(s64)
42+
RET_ReallyLR implicit $s0
43+
...
44+
---
45+
name: load_gets_fpr
46+
legalized: true
47+
regBankSelected: false
48+
tracksRegLiveness: true
49+
body: |
50+
bb.0:
51+
liveins: $x0
52+
; CHECK-LABEL: name: load_gets_fpr
53+
; CHECK: liveins: $x0
54+
; CHECK: %ptr:gpr(p0) = COPY $x0
55+
; CHECK: %load:fpr(s32) = G_LOAD %ptr(p0) :: (load (s32))
56+
; CHECK: %lround:gpr(s64) = G_LROUND %load(s32)
57+
; CHECK: $d0 = COPY %lround(s64)
58+
; CHECK: RET_ReallyLR implicit $s0
59+
%ptr:_(p0) = COPY $x0
60+
%load:_(s32) = G_LOAD %ptr(p0) :: (load (s32))
61+
%lround:_(s64) = G_LROUND %load
62+
$d0 = COPY %lround:_(s64)
63+
RET_ReallyLR implicit $s0
64+
65+
...

0 commit comments

Comments
 (0)