[llvm] d5ed0d4 - [Live Intervals] Factor-out unionBitMask. NFC.

Serguei Katkov via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 13 20:55:02 PDT 2021


Author: Serguei Katkov
Date: 2021-04-14T10:39:01+07:00
New Revision: d5ed0d4816fee73cb508cbb68be2444412093af7

URL: https://github.com/llvm/llvm-project/commit/d5ed0d4816fee73cb508cbb68be2444412093af7
DIFF: https://github.com/llvm/llvm-project/commit/d5ed0d4816fee73cb508cbb68be2444412093af7.diff

LOG: [Live Intervals] Factor-out unionBitMask. NFC.

For further re-usage in other place.

Added: 
    

Modified: 
    llvm/lib/CodeGen/LiveIntervals.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/LiveIntervals.cpp b/llvm/lib/CodeGen/LiveIntervals.cpp
index e858efe5a68c..7fc012ae4eba 100644
--- a/llvm/lib/CodeGen/LiveIntervals.cpp
+++ b/llvm/lib/CodeGen/LiveIntervals.cpp
@@ -914,11 +914,8 @@ bool LiveIntervals::checkRegMaskInterference(LiveInterval &LI,
     return false;
 
   bool Found = false;
-  while (true) {
-    assert(*SlotI >= LiveI->start);
-    // Loop over all slots overlapping this segment.
-    while (*SlotI < LiveI->end) {
-      // *SlotI overlaps LI. Collect mask bits.
+  // Utility to union regmasks.
+  auto unionBitMask = [&](unsigned Idx) {
       if (!Found) {
         // This is the first overlap. Initialize UsableRegs to all ones.
         UsableRegs.clear();
@@ -926,7 +923,14 @@ bool LiveIntervals::checkRegMaskInterference(LiveInterval &LI,
         Found = true;
       }
       // Remove usable registers clobbered by this mask.
-      UsableRegs.clearBitsNotInMask(Bits[SlotI-Slots.begin()]);
+      UsableRegs.clearBitsNotInMask(Bits[Idx]);
+  };
+  while (true) {
+    assert(*SlotI >= LiveI->start);
+    // Loop over all slots overlapping this segment.
+    while (*SlotI < LiveI->end) {
+      // *SlotI overlaps LI. Collect mask bits.
+      unionBitMask(SlotI - Slots.begin());
       if (++SlotI == SlotE)
         return Found;
     }


        


More information about the llvm-commits mailing list