intel/fs/ra: Choose a spill reg before throwing away the graph
authorJason Ekstrand <jason@jlekstrand.net>
Wed, 15 May 2019 03:51:20 +0000 (22:51 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Thu, 16 May 2019 02:13:09 +0000 (02:13 +0000)
Otherwise, we get an effectively random spill reg because we no longer
have the information from RA to guide us.  Also, a completely clean
graph has undefined data in in_stack which is used for choosing the
spill reg so it really is non-deterministic.

Fixes: e99081e76d4 "intel/fs/ra: Spill without destroying the..."
Tested-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/intel/compiler/brw_fs_reg_allocate.cpp

index b7425ea6d58f2f972053486956e7dee30bd9bbea..33631ddcd0ca3c7041af49c4acc3bc69f31c5c50 100644 (file)
@@ -1157,6 +1157,13 @@ fs_reg_alloc::assign_regs(bool allow_spilling, bool spill_all)
       if (!allow_spilling)
          return false;
 
+      /* Failed to allocate registers.  Spill a reg, and the caller will
+       * loop back into here to try again.
+       */
+      int reg = choose_spill_reg();
+      if (reg == -1)
+         return false;
+
       /* If we're going to spill but we've never spilled before, we need to
        * re-build the interference graph with MRFs enabled to allow spilling.
        */
@@ -1167,13 +1174,6 @@ fs_reg_alloc::assign_regs(bool allow_spilling, bool spill_all)
 
       spilled = true;
 
-      /* Failed to allocate registers.  Spill a reg, and the caller will
-       * loop back into here to try again.
-       */
-      int reg = choose_spill_reg();
-      if (reg == -1)
-         return false;
-
       spill_reg(reg);
    }