diff options
author | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-10-29 00:40:59 +0000 |
---|---|---|
committer | Jakob Stoklund Olesen <stoklund@2pi.dk> | 2010-10-29 00:40:59 +0000 |
commit | 13d7e0d012c6e5ab6728bbfb57d52b6bb2ff8ad2 (patch) | |
tree | fe7d77711a94257478db8234c1a2c140a9828d7d /llvm/lib/CodeGen | |
parent | b98755472ebe813251567f1f9eec69b8f468508d (diff) | |
download | bcm5719-llvm-13d7e0d012c6e5ab6728bbfb57d52b6bb2ff8ad2.tar.gz bcm5719-llvm-13d7e0d012c6e5ab6728bbfb57d52b6bb2ff8ad2.zip |
Fix broken equivalence class calculation. We could probably also use
EquvivalenceClasses.h except it looks like overkill when elements are continuous
integers.
llvm-svn: 117631
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/LiveInterval.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/llvm/lib/CodeGen/LiveInterval.cpp b/llvm/lib/CodeGen/LiveInterval.cpp index 6fb60362be6..27a572c0ea7 100644 --- a/llvm/lib/CodeGen/LiveInterval.cpp +++ b/llvm/lib/CodeGen/LiveInterval.cpp @@ -709,15 +709,14 @@ void LiveRange::print(raw_ostream &os) const { /// multiple LiveIntervals. void ConnectedVNInfoEqClasses::Connect(unsigned a, unsigned b) { - unsigned eqa = eqClass_[a]; - unsigned eqb = eqClass_[b]; - if (eqa == eqb) - return; - // Make sure a and b are in the same class while maintaining eqClass_[i] <= i. - if (eqa > eqb) - eqClass_[a] = eqb; - else - eqClass_[b] = eqa; + while (eqClass_[a] != eqClass_[b]) { + if (eqClass_[a] > eqClass_[b]) + std::swap(a, b); + unsigned t = eqClass_[b]; + assert(t <= b && "Invariant broken"); + eqClass_[b] = eqClass_[a]; + b = t; + } } unsigned ConnectedVNInfoEqClasses::Renumber() { @@ -745,8 +744,6 @@ unsigned ConnectedVNInfoEqClasses::Classify(const LiveInterval *LI) { for (LiveInterval::const_vni_iterator I = LI->vni_begin(), E = LI->vni_end(); I != E; ++I) { const VNInfo *VNI = *I; - if (VNI->id == eqClass_.size()) - eqClass_.push_back(VNI->id); assert(!VNI->isUnused() && "Cannot handle unused values"); if (VNI->isPHIDef()) { const MachineBasicBlock *MBB = lis_.getMBBFromIndex(VNI->def); |