Mesa (master): aco/ra: Use std::all_of to simplify a loop
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jan 13 18:31:39 UTC 2021
Module: Mesa
Branch: master
Commit: d9e1375e2718992d965c23a5a9c074037c640a48
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d9e1375e2718992d965c23a5a9c074037c640a48
Author: Tony Wasserka <tony.wasserka at gmx.de>
Date: Thu Oct 29 11:43:51 2020 +0100
aco/ra: Use std::all_of to simplify a loop
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7799>
---
src/amd/compiler/aco_register_allocation.cpp | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/amd/compiler/aco_register_allocation.cpp b/src/amd/compiler/aco_register_allocation.cpp
index ff74900b5ea..57334045d77 100644
--- a/src/amd/compiler/aco_register_allocation.cpp
+++ b/src/amd/compiler/aco_register_allocation.cpp
@@ -828,15 +828,14 @@ std::pair<PhysReg, bool> get_reg_simple(ra_ctx& ctx,
continue;
for (unsigned i = 0; i < 4; i+= info.stride) {
- if (entry.second[i] != 0)
- continue;
+ /* check if there's a block of free bytes large enough to hold the register */
+ bool reg_found = std::all_of(&entry.second[i], &entry.second[std::min(4u, i + rc.bytes())],
+ [](unsigned v) { return v == 0; });
- bool reg_found = true;
- for (unsigned j = 1; reg_found && i + j < 4 && j < rc.bytes(); j++)
- reg_found &= entry.second[i + j] == 0;
+ /* check if also the neighboring reg is free if needed */
+ if (reg_found && i + rc.bytes() > 4)
+ reg_found = (reg_file[entry.first + 1] == 0);
- /* check neighboring reg if needed */
- reg_found &= ((int)i <= 4 - (int)rc.bytes() || reg_file[entry.first + 1] == 0);
if (reg_found) {
PhysReg res{entry.first};
res.reg_b += i;
More information about the mesa-commit
mailing list