summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2016-04-08 16:59:50 +0000
committerQuentin Colombet <qcolombet@apple.com>2016-04-08 16:59:50 +0000
commit88805c191777c0baaac8e2ece214aa7c1c09af85 (patch)
tree9b538bd5d000645ec789993020e1b86559eb508e /llvm/lib
parentb3de24f5e65c4bb170b45e2585ee878c540ba7ae (diff)
downloadbcm5719-llvm-88805c191777c0baaac8e2ece214aa7c1c09af85.tar.gz
bcm5719-llvm-88805c191777c0baaac8e2ece214aa7c1c09af85.zip
[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
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp b/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp
index b312112bb1c..e22401ad352 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;
OpenPOWER on IntegriCloud