diff options
author | Timur Kristóf <timur.kristof@gmail.com> | 2024-03-07 15:20:11 +0100 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-03-19 20:50:12 +0000 |
commit | 58e3b1f930feb70f3294180847aa758f0e76fb26 (patch) | |
tree | 6cee6f62dba11bb7d681d7affedcdf6545151957 | |
parent | d1cac5ed0566ed02f1a522cc690ab5cda1880ec0 (diff) |
aco: Allow passing constant operand to is_overwritten_since.
This is to make it more intuitive and also consistent
with last_writer_idx which does allow constant operands.
Signed-off-by: Timur Kristóf <timur.kristof@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28046>
-rw-r--r-- | src/amd/compiler/aco_optimizer_postRA.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/amd/compiler/aco_optimizer_postRA.cpp b/src/amd/compiler/aco_optimizer_postRA.cpp index e67f56e056d..5a5cd293283 100644 --- a/src/amd/compiler/aco_optimizer_postRA.cpp +++ b/src/amd/compiler/aco_optimizer_postRA.cpp @@ -230,11 +230,19 @@ is_overwritten_since(pr_opt_ctx& ctx, PhysReg reg, RegClass rc, const Idx& since return false; } -template <typename T> bool -is_overwritten_since(pr_opt_ctx& ctx, const T& t, const Idx& idx, bool inclusive = false) +is_overwritten_since(pr_opt_ctx& ctx, const Definition& def, const Idx& idx, bool inclusive = false) { - return is_overwritten_since(ctx, t.physReg(), t.regClass(), idx, inclusive); + return is_overwritten_since(ctx, def.physReg(), def.regClass(), idx, inclusive); +} + +bool +is_overwritten_since(pr_opt_ctx& ctx, const Operand& op, const Idx& idx, bool inclusive = false) +{ + if (op.isConstant()) + return false; + + return is_overwritten_since(ctx, op.physReg(), op.regClass(), idx, inclusive); } void @@ -382,7 +390,7 @@ try_optimize_scc_nocompare(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr) /* Check whether the operands of the writer are overwritten. */ for (const Operand& op : wr_instr->operands) { - if (!op.isConstant() && is_overwritten_since(ctx, op, wr_idx)) + if (is_overwritten_since(ctx, op, wr_idx)) return; } @@ -523,7 +531,7 @@ try_eliminate_scc_copy(pr_opt_ctx& ctx, aco_ptr<Instruction>& instr) /* Verify that the operands of the producer instruction haven't been overwritten. */ for (const Operand& op : producer_instr->operands) { - if (!op.isConstant() && is_overwritten_since(ctx, op, producer_idx, true)) + if (is_overwritten_since(ctx, op, producer_idx, true)) return; } |