Skip to content

Commit 3011aa1

Browse files
author
Jessica Paquette
committed
[AArch64][GlobalISel] Fix regbankselect for G_FCMP with vector destinations
These should always go to a FPR, since they always use the vector registers. Differential Revision: https://reviews.llvm.org/D100885
1 parent 6cb7599 commit 3011aa1

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,15 @@ AArch64RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
719719
break;
720720
OpRegBankIdx = {PMI_FirstGPR, PMI_FirstFPR};
721721
break;
722-
case TargetOpcode::G_FCMP:
723-
OpRegBankIdx = {PMI_FirstGPR,
722+
case TargetOpcode::G_FCMP: {
723+
// If the result is a vector, it must use a FPR.
724+
AArch64GenRegisterBankInfo::PartialMappingIdx Idx0 =
725+
MRI.getType(MI.getOperand(0).getReg()).isVector() ? PMI_FirstFPR
726+
: PMI_FirstGPR;
727+
OpRegBankIdx = {Idx0,
724728
/* Predicate */ PMI_None, PMI_FirstFPR, PMI_FirstFPR};
725729
break;
730+
}
726731
case TargetOpcode::G_BITCAST:
727732
// This is going to be a cross register bank copy and this is expensive.
728733
if (OpRegBankIdx[0] != OpRegBankIdx[1])
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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: vector
7+
legalized: true
8+
tracksRegLiveness: true
9+
body: |
10+
bb.0:
11+
liveins: $q0, $q1
12+
; Vectors should always end up on a FPR.
13+
14+
; CHECK-LABEL: name: vector
15+
; CHECK: liveins: $q0, $q1
16+
; CHECK: %x:fpr(<2 x s64>) = COPY $q0
17+
; CHECK: %y:fpr(<2 x s64>) = COPY $q1
18+
; CHECK: %fcmp:fpr(<2 x s64>) = G_FCMP floatpred(olt), %x(<2 x s64>), %y
19+
; CHECK: $q0 = COPY %fcmp(<2 x s64>)
20+
; CHECK: RET_ReallyLR implicit $q0
21+
%x:_(<2 x s64>) = COPY $q0
22+
%y:_(<2 x s64>) = COPY $q1
23+
%fcmp:_(<2 x s64>) = G_FCMP floatpred(olt), %x:_(<2 x s64>), %y:_
24+
$q0 = COPY %fcmp
25+
RET_ReallyLR implicit $q0
26+
...

0 commit comments

Comments
 (0)