From 88805c191777c0baaac8e2ece214aa7c1c09af85 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Fri, 8 Apr 2016 16:59:50 +0000 Subject: [PATCH] [RegisterBankInfo] Change the implementation for the default mapping. Do not give that much importance to the current register bank of an operand. This is likely just a side effect of the current execution and it is properly wise to prefer a register bank that can be extracted from the information available statically (like encoding constraints and type). llvm-svn: 265810 --- llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp index b312112..e22401a 100644 --- a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp +++ b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp @@ -250,7 +250,16 @@ RegisterBankInfo::getInstrMappingImpl(const MachineInstr &MI) const { unsigned Reg = MO.getReg(); if (!Reg) continue; - const RegisterBank *CurRegBank = getRegBank(Reg, MRI, TRI); + // The register bank of Reg is just a side effect of the current + // excution and in particular, there is no reason to believe this + // is the best default mapping for the current instruction. Keep + // it as an alternative register bank if we cannot figure out + // something. + const RegisterBank *AltRegBank = getRegBank(Reg, MRI, TRI); + // For copy-like instruction, we want to reuse the register bank + // that is already set on Reg, if any, since those instructions do + // not have any constraints. + const RegisterBank *CurRegBank = isCopyLike ? AltRegBank : nullptr; if (!CurRegBank) { // If this is a target specific instruction, we can deduce // the register bank from the encoding constraints. @@ -262,6 +271,10 @@ RegisterBankInfo::getInstrMappingImpl(const MachineInstr &MI) const { if (MITy) CurRegBank = getRegBankForType( MVT::getVT(MITy, /*HandleUnknown*/ true).SimpleTy); + if (!CurRegBank) + // Use the current assigned register bank. + // That may not make much sense though. + CurRegBank = AltRegBank; if (!CurRegBank) { // All our attempts failed, give up. CompleteMapping = false; -- 2.7.4