diff options
author | Lang Hames <lhames@gmail.com> | 2009-05-14 04:26:30 +0000 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2009-05-14 04:26:30 +0000 |
commit | a7c9deaa2b1df30808db376bdfcba7f2e54e59d1 (patch) | |
tree | 68b54692773a3ef08ff6dcabf584453edda4caf0 /lib/CodeGen/TwoAddressInstructionPass.cpp | |
parent | f95701286664df01a5683a71c9a02c056fed0aa7 (diff) |
Fix for PR4124. Make TwoAddressFormPass::FindLastUseInMBB return the real last use.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71769 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/TwoAddressInstructionPass.cpp')
-rw-r--r-- | lib/CodeGen/TwoAddressInstructionPass.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp index 2ec0c71222..6282a4ab55 100644 --- a/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -316,7 +316,7 @@ bool TwoAddressInstructionPass::NoUseAfterLastDef(unsigned Reg, MachineInstr *TwoAddressInstructionPass::FindLastUseInMBB(unsigned Reg, MachineBasicBlock *MBB, unsigned Dist) { - unsigned LastUseDist = Dist; + unsigned LastUseDist = 0; MachineInstr *LastUse = 0; for (MachineRegisterInfo::reg_iterator I = MRI->reg_begin(Reg), E = MRI->reg_end(); I != E; ++I) { @@ -327,7 +327,10 @@ MachineInstr *TwoAddressInstructionPass::FindLastUseInMBB(unsigned Reg, DenseMap<MachineInstr*, unsigned>::iterator DI = DistanceMap.find(MI); if (DI == DistanceMap.end()) continue; - if (MO.isUse() && DI->second < LastUseDist) { + if (DI->second >= Dist) + continue; + + if (MO.isUse() && DI->second > LastUseDist) { LastUse = DI->first; LastUseDist = DI->second; } |