From 4131bc3b0cb07ffd7f87e2d10a9ebbb327298f80 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 2 Oct 2020 13:46:35 -0400 Subject: [PATCH] pan/bi: Use canonical next_clause_prefetch Signed-off-by: Alyssa Rosenzweig Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/bifrost/bi_pack.c | 4 +--- src/panfrost/bifrost/bi_print.c | 5 ++++- src/panfrost/bifrost/bi_schedule.c | 10 ++++++---- src/panfrost/bifrost/bifrost.h | 9 ++++----- src/panfrost/bifrost/compiler.h | 5 ++++- src/panfrost/bifrost/disassemble.c | 7 +++---- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/panfrost/bifrost/bi_pack.c b/src/panfrost/bifrost/bi_pack.c index 8fef1a4e1bb..7e758a53ab6 100644 --- a/src/panfrost/bifrost/bi_pack.c +++ b/src/panfrost/bifrost/bi_pack.c @@ -48,7 +48,7 @@ bi_pack_header(bi_clause *clause, bi_clause *next_1, bi_clause *next_2, bool is_ .back_to_back = clause->back_to_back, .no_end_of_shader = (next_1 != NULL), .terminate_discarded_threads = is_fragment, - .branch_cond = clause->branch_conditional || clause->back_to_back, + .next_clause_prefetch = clause->next_clause_prefetch, .datareg_writebarrier = clause->data_register_write_barrier, .datareg = clause->data_register, .scoreboard_deps = scoreboard_deps, @@ -59,8 +59,6 @@ bi_pack_header(bi_clause *clause, bi_clause *next_1, bi_clause *next_2, bool is_ .suppress_nan = true, }; - header.branch_cond |= header.back_to_back; - uint64_t u = 0; memcpy(&u, &header, sizeof(header)); return u; diff --git a/src/panfrost/bifrost/bi_print.c b/src/panfrost/bifrost/bi_print.c index a97663c067c..e30ef8adbfb 100644 --- a/src/panfrost/bifrost/bi_print.c +++ b/src/panfrost/bifrost/bi_print.c @@ -410,7 +410,10 @@ bi_print_clause(bi_clause *clause, FILE *fp) } if (!clause->back_to_back) - fprintf(fp, " nbb %s", clause->branch_conditional ? "branch-cond" : "branch-uncond"); + fprintf(fp, " nbb"); + + if (!clause->next_clause_prefetch) + fprintf(fp, " no_prefetch"); if (clause->data_register_write_barrier) fprintf(fp, " drwb"); diff --git a/src/panfrost/bifrost/bi_schedule.c b/src/panfrost/bifrost/bi_schedule.c index a336e5ea7ae..ea526a14601 100644 --- a/src/panfrost/bifrost/bi_schedule.c +++ b/src/panfrost/bifrost/bi_schedule.c @@ -227,11 +227,13 @@ bi_schedule(bi_context *ctx) u->constants[0] = ins->constant.u64; /* No indirect jumps yet */ - if (ins->type == BI_BRANCH) { + if (ins->type == BI_BRANCH) u->branch_constant = true; - u->branch_conditional = - (ins->cond != BI_COND_ALWAYS); - } + + /* We always prefetch except unconditional branches */ + u->next_clause_prefetch = !( + (ins->type == BI_BRANCH) && + (ins->cond == BI_COND_ALWAYS)); u->clause_type = bi_clause_type_for_ins(ins); u->block = (struct bi_block *) block; diff --git a/src/panfrost/bifrost/bifrost.h b/src/panfrost/bifrost/bifrost.h index acb1035ed40..d57df43a9e8 100644 --- a/src/panfrost/bifrost/bifrost.h +++ b/src/panfrost/bifrost/bifrost.h @@ -88,11 +88,10 @@ struct bifrost_header { * for fragment shaders for standard GL behaviour of DISCARD. */ unsigned terminate_discarded_threads : 1; - // If backToBack is off: - // - true for conditional branches and fallthrough - // - false for unconditional branches - // The blob seems to always set it to true if back-to-back is on. - unsigned branch_cond : 1; + /* If set, the hardware may prefetch the next clause. If false, the + * hardware may not. Clear for unconditional branches. */ + unsigned next_clause_prefetch : 1; + // This bit is set when the next clause writes to the data register of some // previous clause. unsigned datareg_writebarrier: 1; diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h index eaacf7423da..c13a7e9cd7c 100644 --- a/src/panfrost/bifrost/compiler.h +++ b/src/panfrost/bifrost/compiler.h @@ -400,7 +400,10 @@ typedef struct { * the emitted code it's always set if back-to-bit is, whereas we use * the actual value (without back-to-back so to speak) internally */ bool back_to_back; - bool branch_conditional; + + /* Can we prefetch the next clause? Usually it makes sense, except for + * clauses ending in unconditional branches */ + bool next_clause_prefetch; /* Assigned data register */ unsigned data_register; diff --git a/src/panfrost/bifrost/disassemble.c b/src/panfrost/bifrost/disassemble.c index 0b972b4dc4d..83be8d599b1 100644 --- a/src/panfrost/bifrost/disassemble.c +++ b/src/panfrost/bifrost/disassemble.c @@ -109,10 +109,6 @@ static void dump_header(FILE *fp, struct bifrost_header header, bool verbose) if (!header.back_to_back) { fprintf(fp, "nbb "); - if (header.branch_cond) - fprintf(fp, "branch-cond "); - else - fprintf(fp, "branch-uncond "); } if (header.suppress_inf) @@ -146,6 +142,9 @@ static void dump_header(FILE *fp, struct bifrost_header header, bool verbose) if (header.terminate_discarded_threads) fprintf(fp, "td "); + if (header.next_clause_prefetch) + fprintf(fp, "ncph "); + fprintf(fp, "\n"); if (verbose) {