- // Pick the register class of the right type that contains this physreg.
- SmallVector<const TargetRegisterClass*, 4> RCs;
- for (regclass_iterator I = regclass_begin(), E = regclass_end(); I != E; ++I) {
- if ((VT == MVT::Other || (*I)->hasType(VT)) && (*I)->contains(reg))
- RCs.push_back(*I);
- }
-
- if (RCs.size() == 1)
- return RCs[0];
-
- if (RCs.size()) {
- // Multiple compatible register classes. Get the super- class.
- std::stable_sort(RCs.begin(), RCs.end(), RCCompare());
- return RCs[0];
+ // Pick the most super register class of the right type that contains
+ // this physreg.
+ const TargetRegisterClass* BestRC = 0;
+ for (regclass_iterator I = regclass_begin(), E = regclass_end(); I != E; ++I){
+ const TargetRegisterClass* RC = *I;
+ if ((VT == MVT::Other || RC->hasType(VT)) && RC->contains(reg) &&
+ (!BestRC || BestRC->hasSuperClass(RC)))
+ BestRC = RC;