Avoid creating BitVector temporaries.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Sun, 29 Jan 2012 01:29:25 +0000 (01:29 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Sun, 29 Jan 2012 01:29:25 +0000 (01:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149188 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/RegisterScavenging.cpp

index 16c5898e168347ef38bc6a660928cca1a194f306..7620cbbc42d307129dedefccbbb9bd309f5771fa 100644 (file)
@@ -234,10 +234,10 @@ void RegScavenger::forward() {
 }
 
 void RegScavenger::getRegsUsed(BitVector &used, bool includeReserved) {
-  if (includeReserved)
-    used = ~RegsAvailable;
-  else
-    used = ~RegsAvailable & ~ReservedRegs;
+  used = RegsAvailable;
+  if (!includeReserved)
+    used |= ReservedRegs;
+  used.flip();
 }
 
 unsigned RegScavenger::FindUnusedReg(const TargetRegisterClass *RC) const {
@@ -352,9 +352,9 @@ unsigned RegScavenger::scavengeRegister(const TargetRegisterClass *RC,
   // RegsAvailable, as RegsAvailable does not take aliases into account.
   // That's what getRegsAvailable() is for.
   BitVector Available = getRegsAvailable(RC);
-
-  if ((Candidates & Available).any())
-     Candidates &= Available;
+  Available &= Candidates;
+  if (Available.any())
+    Candidates = Available;
 
   // Find the register whose use is furthest away.
   MachineBasicBlock::iterator UseMI;