]> granicus.if.org Git - llvm/commitdiff
[AArch64][RegisterBankInfo] Use a proper cost for cross regbank G_BITCASTs.
authorQuentin Colombet <qcolombet@apple.com>
Thu, 13 Oct 2016 00:11:57 +0000 (00:11 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Thu, 13 Oct 2016 00:11:57 +0000 (00:11 +0000)
This does not change anything yet, because we do not offer any
alternative mapping.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284087 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AArch64/AArch64RegisterBankInfo.cpp

index 5b2c2318d67facf8fc62e35396988ba3ab8b6d4b..69ba5023f939e39183cbf41ba9c24cdc629892bf 100644 (file)
@@ -383,8 +383,6 @@ AArch64RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
   }
 
   unsigned NumOperands = MI.getNumOperands();
-  RegisterBankInfo::InstructionMapping Mapping =
-      InstructionMapping{DefaultMappingID, 1, nullptr, NumOperands};
 
   // Track the size and bank of each register.  We don't do partial mappings.
   SmallVector<unsigned, 4> OpSize(NumOperands);
@@ -405,6 +403,7 @@ AArch64RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
       OpRegBankIdx[Idx] = AArch64::FirstGPR;
   }
 
+  unsigned Cost = 1;
   // Some of the floating-point instructions have mixed GPR and FPR operands:
   // fine-tune the computed mapping.
   switch (Opc) {
@@ -424,9 +423,19 @@ AArch64RegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
                     AArch64::FirstFPR, AArch64::FirstFPR};
     break;
   }
+  case TargetOpcode::G_BITCAST: {
+    // This is going to be a cross register bank copy and this is expensive.
+    if (OpRegBankIdx[0] != OpRegBankIdx[1])
+      Cost =
+          copyCost(*AArch64::PartMappings[OpRegBankIdx[0]].RegBank,
+                   *AArch64::PartMappings[OpRegBankIdx[1]].RegBank, OpSize[0]);
+    break;
+  }
   }
 
   // Finally construct the computed mapping.
+  RegisterBankInfo::InstructionMapping Mapping =
+      InstructionMapping{DefaultMappingID, Cost, nullptr, NumOperands};
   SmallVector<const ValueMapping *, 8> OpdsMapping(NumOperands);
   for (unsigned Idx = 0; Idx < NumOperands; ++Idx)
     if (MI.getOperand(Idx).isReg())