diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-02-13 08:41:08 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-02-13 08:41:08 +0000 |
commit | f06d6abeb34c28bd57bbc4ae09aa9b4adf921f71 (patch) | |
tree | da142b553551f637fef4dad65a5775ae324169dd | |
parent | e2ea35b1c8fc6b056d6741cb9a3a5154bcbe1dbb (diff) | |
download | external_llvm-f06d6abeb34c28bd57bbc4ae09aa9b4adf921f71.zip external_llvm-f06d6abeb34c28bd57bbc4ae09aa9b4adf921f71.tar.gz external_llvm-f06d6abeb34c28bd57bbc4ae09aa9b4adf921f71.tar.bz2 |
* Cannot safely commute an instruction there are other defs which can reach its uses.
* Ignore copy instructions which have already been coalesced.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47056 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/SimpleRegisterCoalescing.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp index 94a94a1..df5d3fa 100644 --- a/lib/CodeGen/SimpleRegisterCoalescing.cpp +++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp @@ -237,7 +237,9 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(LiveInterval &IntA, // AValNo is the value number in A that defines the copy, A3 in the example. LiveInterval::iterator ALR = IntA.FindLiveRangeContaining(CopyIdx-1); VNInfo *AValNo = ALR->valno; - if (AValNo->def == ~0U || AValNo->def == ~1U) + // If other defs can reach uses of this def, then it's not safe to perform + // the optimization. + if (AValNo->def == ~0U || AValNo->def == ~1U || AValNo->hasPHIKill) return false; MachineInstr *DefMI = li_->getInstructionFromIndex(AValNo->def); const TargetInstrDesc &TID = DefMI->getDesc(); @@ -312,6 +314,8 @@ bool SimpleRegisterCoalescing::RemoveCopyByCommutingDef(LiveInterval &IntA, MachineOperand &UseMO = UI.getOperand(); ++UI; MachineInstr *UseMI = UseMO.getParent(); + if (JoinedCopies.count(UseMI)) + continue; unsigned UseIdx = li_->getInstructionIndex(UseMI); LiveInterval::iterator ULR = IntA.FindLiveRangeContaining(UseIdx); if (ULR->valno != AValNo) |