Index: lib/CodeGen/RegUsageInfoCollector.cpp =================================================================== --- lib/CodeGen/RegUsageInfoCollector.cpp +++ lib/CodeGen/RegUsageInfoCollector.cpp @@ -171,28 +171,27 @@ } // Insert any register fully saved via subregisters. - for (unsigned PReg = 1, PRegE = TRI->getNumRegs(); PReg < PRegE; ++PReg) { - if (SavedRegs.test(PReg)) + for (const TargetRegisterClass *RC : TRI->regclasses()) { + if (!RC->CoveredBySubRegs) continue; - // Check if PReg is fully covered by its subregs. - bool CoveredBySubRegs = false; - for (const TargetRegisterClass *RC : TRI->regclasses()) - if (RC->CoveredBySubRegs && RC->contains(PReg)) { - CoveredBySubRegs = true; - break; - } - if (!CoveredBySubRegs) - continue; - - // Add PReg to SavedRegs if all subregs are saved. - bool AllSubRegsSaved = true; - for (MCSubRegIterator SR(PReg, TRI, false); SR.isValid(); ++SR) - if (!SavedRegs.test(*SR)) { - AllSubRegsSaved = false; - break; - } - if (AllSubRegsSaved) - SavedRegs.set(PReg); + for (unsigned PReg = 1, PRegE = TRI->getNumRegs(); PReg < PRegE; ++PReg) { + if (SavedRegs.test(PReg)) + continue; + + // Check if PReg is fully covered by its subregs. + if (!RC->contains(PReg)) + continue; + + // Add PReg to SavedRegs if all subregs are saved. + bool AllSubRegsSaved = true; + for (MCSubRegIterator SR(PReg, TRI, false); SR.isValid(); ++SR) + if (!SavedRegs.test(*SR)) { + AllSubRegsSaved = false; + break; + } + if (AllSubRegsSaved) + SavedRegs.set(PReg); + } } }