Use MCRegUnitIterator to compute regsOverlap().
[oota-llvm.git] / include / llvm / Target / TargetRegisterInfo.h
index 7e73db3a448df24dcbb2ad08398d29a051ae84f4..949fce846120ff151d2b358b961849383d698db4 100644 (file)
@@ -337,9 +337,15 @@ public:
     if (regA == regB) return true;
     if (isVirtualRegister(regA) || isVirtualRegister(regB))
       return false;
-    for (const uint16_t *regList = getOverlaps(regA)+1; *regList; ++regList) {
-      if (*regList == regB) return true;
-    }
+
+    // Regunits are numerically ordered. Find a common unit.
+    MCRegUnitIterator RUA(regA, this);
+    MCRegUnitIterator RUB(regB, this);
+    do {
+      if (*RUA == *RUB) return true;
+      if (*RUA < *RUB) ++RUA;
+      else             ++RUB;
+    } while (RUA.isValid() && RUB.isValid());
     return false;
   }