[llvm] r265810 - [RegisterBankInfo] Change the implementation for the default mapping.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 8 09:59:50 PDT 2016
Author: qcolombet
Date: Fri Apr 8 11:59:50 2016
New Revision: 265810
URL: http://llvm.org/viewvc/llvm-project?rev=265810&view=rev
Log:
[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).
Modified:
llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
Modified: llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp?rev=265810&r1=265809&r2=265810&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp Fri Apr 8 11:59:50 2016
@@ -250,7 +250,16 @@ RegisterBankInfo::getInstrMappingImpl(co
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(co
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;
More information about the llvm-commits
mailing list