Use find_first/find_next to iterate through all the set bits in a
authorDan Gohman <gohman@apple.com>
Thu, 13 Nov 2008 16:31:27 +0000 (16:31 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 13 Nov 2008 16:31:27 +0000 (16:31 +0000)
BitVector, instead of manually testing each bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59246 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/LiveIntervalAnalysis.cpp
lib/CodeGen/LiveVariables.cpp

index 1709618037c1238480d485b76485f36c8fde00b3..a51291298b9ea6d269e3a402dbc3ecb86157b14b 100644 (file)
@@ -399,14 +399,13 @@ void LiveIntervals::handleVirtualRegisterDef(MachineBasicBlock *mbb,
     // Iterate over all of the blocks that the variable is completely
     // live in, adding [insrtIndex(begin), instrIndex(end)+4) to the
     // live interval.
-    for (unsigned i = 0, e = vi.AliveBlocks.size(); i != e; ++i) {
-      if (vi.AliveBlocks[i]) {
-        LiveRange LR(getMBBStartIdx(i),
-                     getMBBEndIdx(i)+1,  // MBB ends at -1.
-                     ValNo);
-        interval.addRange(LR);
-        DOUT << " +" << LR;
-      }
+    for (int i = vi.AliveBlocks.find_first(); i != -1;
+         i = vi.AliveBlocks.find_next(i)) {
+      LiveRange LR(getMBBStartIdx(i),
+                   getMBBEndIdx(i)+1,  // MBB ends at -1.
+                   ValNo);
+      interval.addRange(LR);
+      DOUT << " +" << LR;
     }
 
     // Finally, this virtual register is live from the start of any killing
index 632cd8210ab0295363fb98a1a3072703120cc59b..9fe42f644d638273f0e343063e4b4aa993675ef6 100644 (file)
@@ -52,11 +52,11 @@ void LiveVariables::getAnalysisUsage(AnalysisUsage &AU) const {
 
 void LiveVariables::VarInfo::dump() const {
   cerr << "  Alive in blocks: ";
-  for (unsigned i = 0, e = AliveBlocks.size(); i != e; ++i)
-    if (AliveBlocks[i]) cerr << i << ", ";
+  for (int i = AliveBlocks.find_first(); i != -1; i = AliveBlocks.find_next(i))
+    cerr << i << ", ";
   cerr << "  Used in blocks: ";
-  for (unsigned i = 0, e = UsedBlocks.size(); i != e; ++i)
-    if (UsedBlocks[i]) cerr << i << ", ";
+  for (int i = UsedBlocks.find_first(); i != -1; i = UsedBlocks.find_next(i))
+    cerr << i << ", ";
   cerr << "\n  Killed by:";
   if (Kills.empty())
     cerr << " No instructions.\n";