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 | eeaae20be02979a5d1459cc479c4533be3c05ed5 (patch) | |
tree | ce409ca2847ac5b2ce4219c5b943c443b340022b /lib/CodeGen/LiveInterval.cpp | |
parent | cb367778c0fb3200292df4f3982f54167444d1f6 (diff) |
Fix broken equivalence class calculation. We could probably also use
EquvivalenceClasses.h except it looks like overkill when elements are continuous
integers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@117631 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/LiveInterval.cpp')
-rw-r--r-- | lib/CodeGen/LiveInterval.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp index 6fb60362be..27a572c0ea 100644 --- a/lib/CodeGen/LiveInterval.cpp +++ b/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); |