Mesa (staging/21.2): aco/optimize_postRA: Use iterators instead of operator[] of std::array.
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Sep 16 16:49:29 UTC 2021
Module: Mesa
Branch: staging/21.2
Commit: b4af71448df1abcbeb88536254dff080327b374d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=b4af71448df1abcbeb88536254dff080327b374d
Author: Timur Kristóf <timur.kristof at gmail.com>
Date: Wed Sep 1 18:28:51 2021 +0200
aco/optimize_postRA: Use iterators instead of operator[] of std::array.
Also add a few more assertions to make sure the registers are
within the bounds of the array.
Cc: mesa-stable
Signed-off-by: Timur Kristóf <timur.kristof at gmail.com>
Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Tony Wasserka <tony.wasserka at gmx.de>
Reviewed-by: Joshua Ashton <joshua at froggi.es>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12894>
---
src/amd/compiler/aco_optimizer_postRA.cpp | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/amd/compiler/aco_optimizer_postRA.cpp b/src/amd/compiler/aco_optimizer_postRA.cpp
index e19d8e1f6f7..f3ab6782afb 100644
--- a/src/amd/compiler/aco_optimizer_postRA.cpp
+++ b/src/amd/compiler/aco_optimizer_postRA.cpp
@@ -72,7 +72,8 @@ save_reg_writes(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr)
assert((r + dw_size) <= max_reg_cnt);
assert(def.size() == dw_size || def.regClass().is_subdword());
- std::fill(&ctx.instr_idx_by_regs[r], &ctx.instr_idx_by_regs[r] + dw_size, idx);
+ std::fill(ctx.instr_idx_by_regs.begin() + r,
+ ctx.instr_idx_by_regs.begin() + r + dw_size, idx);
}
}
@@ -80,10 +81,12 @@ int
last_writer_idx(pr_opt_ctx& ctx, PhysReg physReg, RegClass rc)
{
/* Verify that all of the operand's registers are written by the same instruction. */
+ assert(physReg.reg() < max_reg_cnt);
int instr_idx = ctx.instr_idx_by_regs[physReg.reg()];
unsigned dw_size = DIV_ROUND_UP(rc.bytes(), 4u);
unsigned r = physReg.reg();
- bool all_same = std::all_of(&ctx.instr_idx_by_regs[r], &ctx.instr_idx_by_regs[r + dw_size],
+ bool all_same = std::all_of(ctx.instr_idx_by_regs.begin() + r,
+ ctx.instr_idx_by_regs.begin() + r + dw_size,
[instr_idx](int i) { return i == instr_idx; });
return all_same ? instr_idx : written_by_multiple_instrs;
@@ -95,6 +98,7 @@ last_writer_idx(pr_opt_ctx& ctx, const Operand& op)
if (op.isConstant() || op.isUndefined())
return const_or_undef;
+ assert(op.physReg().reg() < max_reg_cnt);
int instr_idx = ctx.instr_idx_by_regs[op.physReg().reg()];
#ifndef NDEBUG
More information about the mesa-commit
mailing list