aco: stop get_reg_simple after reaching max_used_gpr
authorDaniel Schürmann <daniel@schuermann.dev>
Tue, 14 Apr 2020 11:15:56 +0000 (12:15 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 22 Apr 2020 18:23:23 +0000 (18:23 +0000)
Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4573>

src/amd/compiler/aco_register_allocation.cpp

index 11b54ba833941460676c401b5e3015194a9a923e..9a36019ff37916c496efba2687c2dee416fb8c24 100644 (file)
@@ -408,10 +408,16 @@ std::pair<PhysReg, bool> get_reg_simple(ra_ctx& ctx,
       unsigned last_pos = 0xFFFF;
 
       for (unsigned current_reg = lb; current_reg < ub; current_reg++) {
+
          if (reg_file[current_reg] == 0 && !ctx.war_hint[current_reg]) {
             if (last_pos == 0xFFFF)
                last_pos = current_reg;
-            continue;
+
+            /* stop searching after max_used_gpr */
+            if (current_reg == ctx.max_used_sgpr + 1 || current_reg == 256 + ctx.max_used_vgpr + 1)
+               break;
+            else
+               continue;
          }
 
          if (last_pos == 0xFFFF)