X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fvc4%2Fvc4_opt_peephole_sf.c;h=577290b1fc46649caf264b753ec8ce1b1ad26c50;hb=ad1a4cb563f483a5767431adcc6a1a8f973326fd;hp=5536f8dd204e998970399013debb94307e28f581;hpb=8f2af4763a60c5ea5f64829321ae97bbfa51a4ce;p=mesa.git diff --git a/src/gallium/drivers/vc4/vc4_opt_peephole_sf.c b/src/gallium/drivers/vc4/vc4_opt_peephole_sf.c index 5536f8dd204..577290b1fc4 100644 --- a/src/gallium/drivers/vc4/vc4_opt_peephole_sf.c +++ b/src/gallium/drivers/vc4/vc4_opt_peephole_sf.c @@ -62,7 +62,7 @@ inst_srcs_updated(struct qinst *inst, struct qinst *writer) */ switch (writer->dst.file) { case QFILE_TEMP: - for (int i = 0; i < qir_get_op_nsrc(inst->op); i++) { + for (int i = 0; i < qir_get_nsrc(inst); i++) { if (inst->src[i].file == QFILE_TEMP && inst->src[i].index == writer->dst.index) { return true; @@ -95,7 +95,7 @@ inst_result_equals(struct qinst *a, struct qinst *b) return false; } - for (int i = 0; i < qir_get_op_nsrc(a->op); i++) { + for (int i = 0; i < qir_get_nsrc(a); i++) { if (!qir_reg_equals(a->src[i], b->src[i]) || src_file_varies_on_reread(a->src[i]) || src_file_varies_on_reread(b->src[i])) { @@ -106,17 +106,21 @@ inst_result_equals(struct qinst *a, struct qinst *b) return true; } -bool -qir_opt_peephole_sf(struct vc4_compile *c) +static bool +qir_opt_peephole_sf_block(struct vc4_compile *c, struct qblock *block) { bool progress = false; + /* We don't have liveness dataflow analysis for flags, but we also + * never generate a use of flags across control flow, so just treat + * them as unused at block exit. + */ bool sf_live = false; struct qinst *last_sf = NULL; /* Walk the block from bottom to top, tracking if the SF is used, and * removing unused or repeated ones. */ - list_for_each_entry_rev(struct qinst, inst, &c->instructions, link) { + qir_for_each_inst_rev(inst, block) { if (inst->sf) { if (!sf_live) { /* Our instruction's SF isn't read, so drop it. @@ -152,3 +156,14 @@ qir_opt_peephole_sf(struct vc4_compile *c) return progress; } + +bool +qir_opt_peephole_sf(struct vc4_compile *c) +{ + bool progress = false; + + qir_for_each_block(block, c) + progress = qir_opt_peephole_sf_block(c, block) || progress; + + return progress; +}