mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 17:29:19 +00:00
Fix RegisterCoalescer::rematerializeTrivialDef() so that it works on flipped
CoalescerPairs. Also, make it take a CoalescerPair directly like other methods of RegisterCoalescer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175123 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c5f147459b
commit
1d46732281
@ -167,8 +167,7 @@ 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(LiveInterval &SrcInt, unsigned DstReg,
|
bool reMaterializeTrivialDef(CoalescerPair &CP, MachineInstr *CopyMI);
|
||||||
MachineInstr *CopyMI);
|
|
||||||
|
|
||||||
/// 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);
|
||||||
@ -732,9 +731,14 @@ 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(LiveInterval &SrcInt,
|
bool RegisterCoalescer::reMaterializeTrivialDef(CoalescerPair &CP,
|
||||||
unsigned DstReg,
|
|
||||||
MachineInstr *CopyMI) {
|
MachineInstr *CopyMI) {
|
||||||
|
unsigned SrcReg = CP.isFlipped() ? CP.getDstReg() : CP.getSrcReg();
|
||||||
|
unsigned DstReg = CP.isFlipped() ? CP.getSrcReg() : CP.getDstReg();
|
||||||
|
if (TargetRegisterInfo::isPhysicalRegister(SrcReg))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
LiveInterval &SrcInt = LIS->getInterval(SrcReg);
|
||||||
SlotIndex CopyIdx = LIS->getInstructionIndex(CopyMI).getRegSlot(true);
|
SlotIndex CopyIdx = LIS->getInstructionIndex(CopyMI).getRegSlot(true);
|
||||||
LiveInterval::iterator SrcLR = SrcInt.FindLiveRangeContaining(CopyIdx);
|
LiveInterval::iterator SrcLR = SrcInt.FindLiveRangeContaining(CopyIdx);
|
||||||
assert(SrcLR != SrcInt.end() && "Live range not found!");
|
assert(SrcLR != SrcInt.end() && "Live range not found!");
|
||||||
@ -1012,9 +1016,7 @@ 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 (!CP.isFlipped() &&
|
if (reMaterializeTrivialDef(CP, CopyMI))
|
||||||
reMaterializeTrivialDef(LIS->getInterval(CP.getSrcReg()),
|
|
||||||
CP.getDstReg(), CopyMI))
|
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1047,9 +1049,7 @@ 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 (!CP.isFlipped() &&
|
if (reMaterializeTrivialDef(CP, CopyMI))
|
||||||
reMaterializeTrivialDef(LIS->getInterval(CP.getSrcReg()),
|
|
||||||
CP.getDstReg(), CopyMI))
|
|
||||||
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user