summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2009-05-14 04:26:30 +0000
committerLang Hames <lhames@gmail.com>2009-05-14 04:26:30 +0000
commit2646b72424633c5c5419277f157754b776f433d9 (patch)
tree44ece3e0e3d6586190f3d2e369c4951a312cfb75 /llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
parent31f099c8c264dae8392a6b2191cb3e26c88908ae (diff)
downloadbcm5719-llvm-2646b72424633c5c5419277f157754b776f433d9.tar.gz
bcm5719-llvm-2646b72424633c5c5419277f157754b776f433d9.zip
Fix for PR4124. Make TwoAddressFormPass::FindLastUseInMBB return the real last use.
llvm-svn: 71769
Diffstat (limited to 'llvm/lib/CodeGen/TwoAddressInstructionPass.cpp')
-rw-r--r--llvm/lib/CodeGen/TwoAddressInstructionPass.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
index 2ec0c712222..6282a4ab554 100644
--- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/llvm/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;
}
OpenPOWER on IntegriCloud