[AArch64][GlobalISel] Regbankselect: Fix G_BUILD_VECTOR trying to use s16 gpr sources.
Since we can't insert s16 gprs as we don't have 16 bit GPR registers, we need to teach RBS to assign them to the FPR bank so our selector works. llvm-svn: 356282
This commit is contained in:
parent
764c2165e8
commit
d55016b276
|
@ -720,10 +720,13 @@ AArch64RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
|
|||
break;
|
||||
|
||||
// Get the instruction that defined the source operand reg, and check if
|
||||
// it's a floating point operation.
|
||||
// it's a floating point operation. Or, if it's a type like s16 which
|
||||
// doesn't have a exact size gpr register class.
|
||||
MachineInstr *DefMI = MRI.getVRegDef(VReg);
|
||||
unsigned DefOpc = DefMI->getOpcode();
|
||||
if (isPreISelGenericFloatingPointOpcode(DefOpc)) {
|
||||
const LLT SrcTy = MRI.getType(VReg);
|
||||
if (isPreISelGenericFloatingPointOpcode(DefOpc) ||
|
||||
SrcTy.getSizeInBits() < 32) {
|
||||
// Have a floating point op.
|
||||
// Make sure every operand gets mapped to a FPR register class.
|
||||
unsigned NumOperands = MI.getNumOperands();
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
|
||||
# RUN: llc -O0 -mtriple arm64-- -run-pass=regbankselect -verify-machineinstrs %s -o - | FileCheck %s
|
||||
---
|
||||
name: build_vec_f16
|
||||
alignment: 2
|
||||
legalized: true
|
||||
tracksRegLiveness: true
|
||||
body: |
|
||||
bb.0:
|
||||
liveins: $w0
|
||||
|
||||
; Check that s16 operands are assigned fpr as we don't have 16 bit gpr regs.
|
||||
; CHECK-LABEL: name: build_vec_f16
|
||||
; CHECK: liveins: $w0
|
||||
; CHECK: [[COPY:%[0-9]+]]:gpr(s32) = COPY $w0
|
||||
; CHECK: [[TRUNC:%[0-9]+]]:gpr(s16) = G_TRUNC [[COPY]](s32)
|
||||
; CHECK: [[COPY1:%[0-9]+]]:fpr(s16) = COPY [[TRUNC]](s16)
|
||||
; CHECK: [[COPY2:%[0-9]+]]:fpr(s16) = COPY [[TRUNC]](s16)
|
||||
; CHECK: [[COPY3:%[0-9]+]]:fpr(s16) = COPY [[TRUNC]](s16)
|
||||
; CHECK: [[COPY4:%[0-9]+]]:fpr(s16) = COPY [[TRUNC]](s16)
|
||||
; CHECK: [[COPY5:%[0-9]+]]:fpr(s16) = COPY [[TRUNC]](s16)
|
||||
; CHECK: [[COPY6:%[0-9]+]]:fpr(s16) = COPY [[TRUNC]](s16)
|
||||
; CHECK: [[COPY7:%[0-9]+]]:fpr(s16) = COPY [[TRUNC]](s16)
|
||||
; CHECK: [[COPY8:%[0-9]+]]:fpr(s16) = COPY [[TRUNC]](s16)
|
||||
; CHECK: [[BUILD_VECTOR:%[0-9]+]]:fpr(<8 x s16>) = G_BUILD_VECTOR [[COPY1]](s16), [[COPY2]](s16), [[COPY3]](s16), [[COPY4]](s16), [[COPY5]](s16), [[COPY6]](s16), [[COPY7]](s16), [[COPY8]](s16)
|
||||
; CHECK: $q0 = COPY [[BUILD_VECTOR]](<8 x s16>)
|
||||
; CHECK: RET_ReallyLR implicit $q0
|
||||
%0:_(s32) = COPY $w0
|
||||
%1:_(s16) = G_TRUNC %0(s32)
|
||||
%2:_(<8 x s16>) = G_BUILD_VECTOR %1(s16), %1(s16), %1(s16), %1(s16), %1(s16), %1(s16), %1(s16), %1(s16)
|
||||
$q0 = COPY %2(<8 x s16>)
|
||||
RET_ReallyLR implicit $q0
|
||||
|
||||
...
|
Loading…
Reference in New Issue