Module: Mesa
Branch: main
Commit: 42f5f9cb8facd74928e3fc306f9f591b219f60bd
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=42f5f9cb8facd74928e3fc306f9f591b219f60bd

Author: M Henning <[email protected]>
Date:   Fri May 12 22:43:22 2023 -0400

nv50/ir: Remove dead loop from assignSlot

This loop can never execute. On entry we have offset = offsetBase and
offsetBase >= stackSize, so the condition offset < stackSize is always
false. The git history suggests that this was always broken this way.

Reviewed-by: Karol Herbst <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23006>

---

 src/nouveau/codegen/nv50_ir_ra.cpp | 43 ++++++++------------------------------
 1 file changed, 9 insertions(+), 34 deletions(-)

diff --git a/src/nouveau/codegen/nv50_ir_ra.cpp 
b/src/nouveau/codegen/nv50_ir_ra.cpp
index fff32b5ba3d..98936ad2646 100644
--- a/src/nouveau/codegen/nv50_ir_ra.cpp
+++ b/src/nouveau/codegen/nv50_ir_ra.cpp
@@ -1578,48 +1578,23 @@ SpillCodeInserter::assignSlot(const Interval &livei, 
const unsigned int size)
    SpillSlot slot;
    int32_t offsetBase = stackSize;
    int32_t offset;
-   std::list<SpillSlot>::iterator pos = slots.end(), it = slots.begin();
+   std::list<SpillSlot>::iterator pos = slots.end();
 
    // Later, we compute the address as (offsetBase + tlsBase)
    // tlsBase might not be size-aligned, so we add just enough
    // to give the final address the correct alignment
    offsetBase = align(offsetBase + func->tlsBase, size) - func->tlsBase;
 
-   slot.sym = NULL;
+   offset = offsetBase;
 
-   for (offset = offsetBase; offset < stackSize; offset += size) {
-      const int32_t entryEnd = offset + size;
-      while (it != slots.end() && it->offset < offset)
-         ++it;
-      if (it == slots.end()) // no slots left
-         break;
-      std::list<SpillSlot>::iterator bgn = it;
+   stackSize = offset + size;
+   slot.offset = offset;
+   slot.sym = new_Symbol(func->getProgram(), FILE_MEMORY_LOCAL);
+   offset += func->tlsBase;
+   slot.sym->setAddress(NULL, offset);
+   slot.sym->reg.size = size;
+   slots.insert(pos, slot)->occup.insert(livei);
 
-      while (it != slots.end() && it->offset < entryEnd) {
-         it->occup.print();
-         if (it->occup.overlaps(livei))
-            break;
-         ++it;
-      }
-      if (it == slots.end() || it->offset >= entryEnd) {
-         // fits
-         for (; bgn != slots.end() && bgn->offset < entryEnd; ++bgn) {
-            bgn->occup.insert(livei);
-            if (bgn->size() == size)
-               slot.sym = bgn->sym;
-         }
-         break;
-      }
-   }
-   if (!slot.sym) {
-      stackSize = offset + size;
-      slot.offset = offset;
-      slot.sym = new_Symbol(func->getProgram(), FILE_MEMORY_LOCAL);
-      offset += func->tlsBase;
-      slot.sym->setAddress(NULL, offset);
-      slot.sym->reg.size = size;
-      slots.insert(pos, slot)->occup.insert(livei);
-   }
    return slot.sym;
 }
 

Reply via email to