mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-06 04:18:00 +00:00
Make rematerialization in the coalescer less sensitive to LRG order.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@184567 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -166,7 +166,8 @@ namespace {
|
|||||||
|
|
||||||
/// reMaterializeTrivialDef - If the source of a copy is defined by a
|
/// reMaterializeTrivialDef - If the source of a copy is defined by a
|
||||||
/// trivial computation, replace the copy by rematerialize the definition.
|
/// trivial computation, replace the copy by rematerialize the definition.
|
||||||
bool reMaterializeTrivialDef(CoalescerPair &CP, MachineInstr *CopyMI);
|
bool reMaterializeTrivialDef(CoalescerPair &CP, MachineInstr *CopyMI,
|
||||||
|
bool &IsDefCopy);
|
||||||
|
|
||||||
/// canJoinPhys - Return true if a physreg copy should be joined.
|
/// canJoinPhys - Return true if a physreg copy should be joined.
|
||||||
bool canJoinPhys(const CoalescerPair &CP);
|
bool canJoinPhys(const CoalescerPair &CP);
|
||||||
@@ -731,7 +732,9 @@ bool RegisterCoalescer::removeCopyByCommutingDef(const CoalescerPair &CP,
|
|||||||
/// reMaterializeTrivialDef - If the source of a copy is defined by a trivial
|
/// reMaterializeTrivialDef - If the source of a copy is defined by a trivial
|
||||||
/// computation, replace the copy by rematerialize the definition.
|
/// computation, replace the copy by rematerialize the definition.
|
||||||
bool RegisterCoalescer::reMaterializeTrivialDef(CoalescerPair &CP,
|
bool RegisterCoalescer::reMaterializeTrivialDef(CoalescerPair &CP,
|
||||||
MachineInstr *CopyMI) {
|
MachineInstr *CopyMI,
|
||||||
|
bool &IsDefCopy) {
|
||||||
|
IsDefCopy = false;
|
||||||
unsigned SrcReg = CP.isFlipped() ? CP.getDstReg() : CP.getSrcReg();
|
unsigned SrcReg = CP.isFlipped() ? CP.getDstReg() : CP.getSrcReg();
|
||||||
unsigned SrcIdx = CP.isFlipped() ? CP.getDstIdx() : CP.getSrcIdx();
|
unsigned SrcIdx = CP.isFlipped() ? CP.getDstIdx() : CP.getSrcIdx();
|
||||||
unsigned DstReg = CP.isFlipped() ? CP.getSrcReg() : CP.getDstReg();
|
unsigned DstReg = CP.isFlipped() ? CP.getSrcReg() : CP.getDstReg();
|
||||||
@@ -750,6 +753,10 @@ bool RegisterCoalescer::reMaterializeTrivialDef(CoalescerPair &CP,
|
|||||||
if (!DefMI)
|
if (!DefMI)
|
||||||
return false;
|
return false;
|
||||||
assert(DefMI && "Defining instruction disappeared");
|
assert(DefMI && "Defining instruction disappeared");
|
||||||
|
if (DefMI->isCopyLike()) {
|
||||||
|
IsDefCopy = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (!DefMI->isAsCheapAsAMove())
|
if (!DefMI->isAsCheapAsAMove())
|
||||||
return false;
|
return false;
|
||||||
if (!TII->isTriviallyReMaterializable(DefMI, AA))
|
if (!TII->isTriviallyReMaterializable(DefMI, AA))
|
||||||
@@ -1064,8 +1071,11 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
|
|||||||
if (!canJoinPhys(CP)) {
|
if (!canJoinPhys(CP)) {
|
||||||
// Before giving up coalescing, if definition of source is defined by
|
// Before giving up coalescing, if definition of source is defined by
|
||||||
// trivial computation, try rematerializing it.
|
// trivial computation, try rematerializing it.
|
||||||
if (reMaterializeTrivialDef(CP, CopyMI))
|
bool IsDefCopy;
|
||||||
|
if (reMaterializeTrivialDef(CP, CopyMI, IsDefCopy))
|
||||||
return true;
|
return true;
|
||||||
|
if (IsDefCopy)
|
||||||
|
Again = true; // May be possible to coalesce later.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1097,7 +1107,8 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
|
|||||||
|
|
||||||
// If definition of source is defined by trivial computation, try
|
// If definition of source is defined by trivial computation, try
|
||||||
// rematerializing it.
|
// rematerializing it.
|
||||||
if (reMaterializeTrivialDef(CP, CopyMI))
|
bool IsDefCopy;
|
||||||
|
if (reMaterializeTrivialDef(CP, CopyMI, IsDefCopy))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// If we can eliminate the copy without merging the live ranges, do so now.
|
// If we can eliminate the copy without merging the live ranges, do so now.
|
||||||
|
|||||||
Reference in New Issue
Block a user