Mesa (main): aco/ra: Fix off-by-one-error in print_regs

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 8 15:29:52 UTC 2021


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

Author: Tony Wasserka <tony.wasserka at gmx.de>
Date:   Thu Apr 29 18:06:53 2021 +0200

aco/ra: Fix off-by-one-error in print_regs

Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Fixes: 3675aefa84e ("aco/ra: Fix build with print_regs enabled")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10517>

---

 src/amd/compiler/aco_register_allocation.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp
index ab643bfdc85..42ef1fd5e14 100644
--- a/src/amd/compiler/aco_register_allocation.cpp
+++ b/src/amd/compiler/aco_register_allocation.cpp
@@ -355,8 +355,7 @@ private:
 /* helper function for debugging */
 UNUSED void print_regs(ra_ctx& ctx, bool vgprs, RegisterFile& reg_file)
 {
-   unsigned max = vgprs ? ctx.program->max_reg_demand.vgpr : ctx.program->max_reg_demand.sgpr;
-   PhysRegInterval regs { vgprs ? PhysReg{256} : PhysReg{0}, max };
+   PhysRegInterval regs = get_reg_bounds(ctx.program, vgprs ? RegType::vgpr : RegType::sgpr);
    char reg_char = vgprs ? 'v' : 's';
 
    /* print markers */
@@ -387,7 +386,7 @@ UNUSED void print_regs(ra_ctx& ctx, bool vgprs, RegisterFile& reg_file)
    }
    printf("\n");
 
-   printf("%u/%u used, %u/%u free\n", max - free_regs, max, free_regs, max);
+   printf("%u/%u used, %u/%u free\n", regs.size - free_regs, regs.size, free_regs, regs.size);
 
    /* print assignments */
    prev = 0;



More information about the mesa-commit mailing list