From: Quentin Colombet Date: Wed, 10 May 2017 15:19:41 +0000 (+0000) Subject: [AArch64][RegisterBankInfo] Change the default mapping of fp stores. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e518f7a661f38e1bb832927ff36938288d3ec9c1;p=llvm [AArch64][RegisterBankInfo] Change the default mapping of fp stores. For stores, check if the stored value is defined by a floating point instruction and if yes, we return a default mapping with FPR instead of GPR. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302679 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Target/AArch64/AArch64RegisterBankInfo.cpp b/lib/Target/AArch64/AArch64RegisterBankInfo.cpp index 2813bfd0d1c..789270c2a34 100644 --- a/lib/Target/AArch64/AArch64RegisterBankInfo.cpp +++ b/lib/Target/AArch64/AArch64RegisterBankInfo.cpp @@ -546,6 +546,17 @@ AArch64RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const { break; } break; + case TargetOpcode::G_STORE: + // Check if that store is fed by fp instructions. + if (OpRegBankIdx[0] == PMI_FirstGPR) { + unsigned VReg = MI.getOperand(0).getReg(); + if (!VReg) + break; + MachineInstr *DefMI = MRI.getVRegDef(VReg); + if (isPreISelGenericFloatingPointOpcode(DefMI->getOpcode())) + OpRegBankIdx[0] = PMI_FirstFPR; + break; + } } // Finally construct the computed mapping. diff --git a/test/CodeGen/AArch64/GlobalISel/arm64-regbankselect.mir b/test/CodeGen/AArch64/GlobalISel/arm64-regbankselect.mir index ece11d7f949..0f054f1d940 100644 --- a/test/CodeGen/AArch64/GlobalISel/arm64-regbankselect.mir +++ b/test/CodeGen/AArch64/GlobalISel/arm64-regbankselect.mir @@ -82,6 +82,13 @@ %res = bitcast double %vres to i64 ret i64 %res } + + define void @floatingPointStore(i64 %arg1, double* %addr) { + %varg1 = bitcast i64 %arg1 to double + %vres = fadd double %varg1, %varg1 + store double %vres, double* %addr + ret void + } ... --- @@ -700,3 +707,42 @@ body: | RET_ReallyLR implicit %x0 ... + +--- +# Make sure we map what looks like floating point +# stores to floating point register bank. +# CHECK-LABEL: name: floatingPointStore +name: floatingPointStore +legalized: true + +# CHECK: registers: +# CHECK-NEXT: - { id: 0, class: gpr } +# CHECK-NEXT: - { id: 1, class: gpr } +# CHECK-NEXT: - { id: 2, class: fpr } +# CHECK-NEXT: - { id: 3, class: fpr } +# CHECK-NEXT: - { id: 4, class: fpr } +registers: + - { id: 0, class: _ } + - { id: 1, class: _ } + - { id: 2, class: _ } + +# CHECK: %0(s64) = COPY %x0 +# CHECK-NEXT: %1(p0) = COPY %x1 +# %0 has been mapped to GPR, we need to repair to match FPR. +# CHECK-NEXT: %3(s64) = COPY %0 +# CHECK-NEXT: %4(s64) = COPY %0 +# CHECK-NEXT: %2(s64) = G_FADD %3, %4 +# CHECK-NEXT: G_STORE %2(s64), %1(p0) :: (store 8 into %ir.addr) +# CHECK-NEXT: RET_ReallyLR + +body: | + bb.0: + liveins: %x0, %x1 + + %0(s64) = COPY %x0 + %1(p0) = COPY %x1 + %2(s64) = G_FADD %0, %0 + G_STORE %2(s64), %1(p0) :: (store 8 into %ir.addr) + RET_ReallyLR + +...