@@ -1849,26 +1849,21 @@ static void computeUberWeights(MutableArrayRef<UberRegSet> UberSets,
18491849 // Skip the first unallocatable set.
18501850 for (UberRegSet &S : UberSets.drop_front ()) {
18511851 // Initialize all unit weights in this set, and remember the max units/reg.
1852- const CodeGenRegister *Reg = nullptr ;
1853- unsigned MaxWeight = 0 , Weight = 0 ;
1854- for (RegUnitIterator UnitI (S.Regs ); UnitI.isValid (); ++UnitI) {
1855- if (Reg != UnitI.getReg ()) {
1856- if (Weight > MaxWeight)
1857- MaxWeight = Weight;
1858- Reg = UnitI.getReg ();
1859- Weight = 0 ;
1860- }
1861- if (!RegBank.getRegUnit (*UnitI).Artificial ) {
1862- unsigned UWeight = RegBank.getRegUnit (*UnitI).Weight ;
1863- if (!UWeight) {
1864- UWeight = 1 ;
1865- RegBank.increaseRegUnitWeight (*UnitI, UWeight);
1852+ unsigned MaxWeight = 0 ;
1853+ for (const CodeGenRegister *R : S.Regs ) {
1854+ unsigned Weight = 0 ;
1855+ for (unsigned U : R->getRegUnits ()) {
1856+ if (!RegBank.getRegUnit (U).Artificial ) {
1857+ unsigned UWeight = RegBank.getRegUnit (U).Weight ;
1858+ if (!UWeight) {
1859+ UWeight = 1 ;
1860+ RegBank.increaseRegUnitWeight (U, UWeight);
1861+ }
1862+ Weight += UWeight;
18661863 }
1867- Weight += UWeight;
18681864 }
1865+ MaxWeight = std::max (MaxWeight, Weight);
18691866 }
1870- if (Weight > MaxWeight)
1871- MaxWeight = Weight;
18721867 if (S.Weight != MaxWeight) {
18731868 LLVM_DEBUG ({
18741869 dbgs () << " UberSet " << &S - UberSets.begin () << " Weight "
0 commit comments