From: Daniel Schürmann Date: Wed, 15 Apr 2020 10:24:39 +0000 (+0100) Subject: aco: use upper part of gap in register file if it is beneficial for striding X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d000d76f13e24aae701de0d4ab43bc06c3c9b361;p=mesa.git aco: use upper part of gap in register file if it is beneficial for striding Totals from affected shaders: SGPRS: 1717288 -> 1716984 (-0.02 %) VGPRS: 1305924 -> 1304904 (-0.08 %) Code Size: 138508892 -> 138420144 (-0.06 %) bytes Max Waves: 115726 -> 115735 (0.01 %) Reviewed-by: Rhys Perry Part-of: --- diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp index eae3822e61c..30be43a7f87 100644 --- a/src/amd/compiler/aco_register_allocation.cpp +++ b/src/amd/compiler/aco_register_allocation.cpp @@ -440,14 +440,25 @@ std::pair get_reg_simple(ra_ctx& ctx, } /* final check */ - if (last_pos + size <= ub && ub - last_pos < gap_size) + if (last_pos + size <= ub && ub - last_pos < gap_size) { best_pos = last_pos; + gap_size = ub - last_pos; + } + + if (best_pos == 0xFFFF) + return {{}, false}; - if (best_pos != 0xFFFF) { - adjust_max_used_regs(ctx, rc, best_pos); - return {PhysReg{best_pos}, true}; + /* find best position within gap by leaving a good stride for other variables*/ + unsigned buffer = gap_size - size; + if (buffer > 1) { + if (((best_pos + size) % 8 != 0 && (best_pos + buffer) % 8 == 0) || + ((best_pos + size) % 4 != 0 && (best_pos + buffer) % 4 == 0) || + ((best_pos + size) % 2 != 0 && (best_pos + buffer) % 2 == 0)) + best_pos = best_pos + buffer; } - return {{}, false}; + + adjust_max_used_regs(ctx, rc, best_pos); + return {PhysReg{best_pos}, true}; } bool found = false;