From d6886bd22cdc2f62b5dfee9db46b895b1463de8e Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Wed, 8 Jun 2016 17:39:43 +0000 Subject: [PATCH] [RegBankSelect] Comment on how we could improve repairing with copies. When repairing with a copy, instead of accounting for the cost of that copy and actually inserting it, we may be able to use an alternative source for the register to repair and just use it. Make sure this is documented, so that we consider that opportunity at some point. llvm-svn: 272176 --- llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp index 5d5a5689d0ea..79b78abe95a7 100644 --- a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp +++ b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp @@ -178,6 +178,17 @@ uint64_t RegBankSelect::getRepairCost( // the repairing. if (MO.isDef()) std::swap(CurRegBank, DesiredRegBrank); + // TODO: It may be possible to actually avoid the copy. + // If we repair something where the source is defined by a copy + // and the source of that copy is on the right bank, we can reuse + // it for free. + // E.g., + // RegToRepair = copy AlternativeSrc + // = op RegToRepair + // We can simply propagate AlternativeSrc instead of copying RegToRepair + // into a new virtual register. + // We would also need to propagate this information in the + // repairing placement. unsigned Cost = RBI->copyCost(*DesiredRegBrank, *CurRegBank, RegisterBankInfo::getSizeInBits(MO.getReg(), *MRI, *TRI));