mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-31 09:25:42 +00:00
Improve logic that decides if its profitable to commute when some of the virtual registers involved have uses/defs chains connecting them to physical register. Fix up the tests that this change improves.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221336 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -545,10 +545,21 @@ isProfitableToCommute(unsigned regA, unsigned regB, unsigned regC,
|
||||
if (ToRegA) {
|
||||
unsigned FromRegB = getMappedReg(regB, SrcRegMap);
|
||||
unsigned FromRegC = getMappedReg(regC, SrcRegMap);
|
||||
bool BComp = !FromRegB || regsAreCompatible(FromRegB, ToRegA, TRI);
|
||||
bool CComp = !FromRegC || regsAreCompatible(FromRegC, ToRegA, TRI);
|
||||
if (BComp != CComp)
|
||||
return !BComp && CComp;
|
||||
bool CompB = FromRegB && regsAreCompatible(FromRegB, ToRegA, TRI);
|
||||
bool CompC = FromRegC && regsAreCompatible(FromRegC, ToRegA, TRI);
|
||||
|
||||
// Compute if any of the following are true:
|
||||
// -RegB is not tied to a register and RegC is compatible with RegA.
|
||||
// -RegB is tied to the wrong physical register, but RegC is.
|
||||
// -RegB is tied to the wrong physical register, and RegC isn't tied.
|
||||
if ((!FromRegB && CompC) || (FromRegB && !CompB && (!FromRegC || CompC)))
|
||||
return true;
|
||||
// Don't compute if any of the following are true:
|
||||
// -RegC is not tied to a register and RegB is compatible with RegA.
|
||||
// -RegC is tied to the wrong physical register, but RegB is.
|
||||
// -RegC is tied to the wrong physical register, and RegB isn't tied.
|
||||
if ((!FromRegC && CompB) || (FromRegC && !CompC && (!FromRegB || CompB)))
|
||||
return false;
|
||||
}
|
||||
|
||||
// If there is a use of regC between its last def (could be livein) and this
|
||||
|
Reference in New Issue
Block a user