Mesa (main): pan/bi: Handle 4-src instructions in scheduler
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jul 12 23:44:38 UTC 2021
Module: Mesa
Branch: main
Commit: e46ec44a51769a1161fc08b5dade31f465182d80
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e46ec44a51769a1161fc08b5dade31f465182d80
Author: Alyssa Rosenzweig <alyssa at collabora.com>
Date: Thu Jul 8 17:32:28 2021 -0400
pan/bi: Handle 4-src instructions in scheduler
Spill to a move. This allows us to emit SHADDX and general CSEL.
Signed-off-by: Alyssa Rosenzweig <alyssa at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10961>
---
src/panfrost/bifrost/bi_schedule.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c
index 3321e0a101d..e4099174004 100644
--- a/src/panfrost/bifrost/bi_schedule.c
+++ b/src/panfrost/bifrost/bi_schedule.c
@@ -833,8 +833,12 @@ bi_instr_schedulable(bi_instr *instr,
unsigned total_srcs = tuple->reg.nr_reads + unique_new_srcs;
- /* TODO: spill to moves */
- if (total_srcs > 3)
+ bool can_spill_to_moves = (!tuple->add);
+ can_spill_to_moves &= (bi_nconstants(clause) < 13 - (clause->tuple_count + 2));
+ can_spill_to_moves &= (clause->tuple_count < 7);
+
+ /* However, we can get an extra 1 or 2 sources by inserting moves */
+ if (total_srcs > (can_spill_to_moves ? 4 : 3))
return false;
/* Count effective reads for the successor */
@@ -924,6 +928,21 @@ bi_take_instr(bi_context *ctx, struct bi_worklist st,
else if (tuple->add && tuple->add->table)
return bi_lower_dtsel(ctx, clause, tuple);
+ /* TODO: Optimize these moves */
+ if (!fma && tuple->nr_prev_reads > 3) {
+ /* Only spill by one source for now */
+ assert(tuple->nr_prev_reads == 4);
+
+ /* Pick a source to spill */
+ bi_index src = tuple->prev_reads[0];
+
+ /* Schedule the spill */
+ bi_builder b = bi_init_builder(ctx, bi_before_tuple(tuple->prev));
+ bi_instr *mov = bi_mov_i32_to(&b, src, src);
+ bi_pop_instr(clause, tuple, mov, live_after_temp, fma);
+ return mov;
+ }
+
#ifndef NDEBUG
/* Don't pair instructions if debugging */
if ((bifrost_debug & BIFROST_DBG_NOSCHED) && tuple->add)
More information about the mesa-commit
mailing list