On Thu, Jul 24, 2014 at 07:54:23PM -0700, Matt Turner wrote: > --- > src/mesa/drivers/dri/i965/brw_cfg.cpp | 59 > +++++++++++++++++++++++++++++++++++ > src/mesa/drivers/dri/i965/brw_cfg.h | 2 ++ > 2 files changed, 61 insertions(+) > > diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp > b/src/mesa/drivers/dri/i965/brw_cfg.cpp > index 3895469..a51d0d2 100644 > --- a/src/mesa/drivers/dri/i965/brw_cfg.cpp > +++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp > @@ -92,6 +92,65 @@ bblock_t::is_successor_of(const bblock_t *block) const > return false; > } > > +static bool > +ends_block(const backend_instruction *inst) > +{ > + enum opcode op = inst->opcode; > + > + return op == BRW_OPCODE_IF || > + op == BRW_OPCODE_ELSE || > + op == BRW_OPCODE_CONTINUE || > + op == BRW_OPCODE_BREAK || > + op == BRW_OPCODE_WHILE; > +} > + > +static bool > +starts_block(const backend_instruction *inst) > +{ > + enum opcode op = inst->opcode; > + > + return op == BRW_OPCODE_DO || > + op == BRW_OPCODE_ENDIF; > +} > + > +bool > +bblock_t::can_combine_with(const bblock_t *that) const > +{ > + if ((const bblock_t *)this->link.next != that) > + return false; > + > + if (ends_block(this->end) || > + starts_block(that->start)) > + return false; > + > + return true; > +} > + > +/* If I merge this into that, we'll revisit on foreach_block_safe. > + * we won't on foreach_block. > + * > + * If I merge that into this, foreach_block_safe won't work > + * foreach_block will. > + *
I need some help here as well. Below the logic merges "that" into "this", right? And the following patch switches to use foreach_block_safe() instead of foreach_block(). Now, the comment here lets me to believe it shouldn't work... > + */ > +void > +bblock_t::combine_with(bblock_t *that) > +{ > + assert(this->can_combine_with(that)); > + foreach_list_typed (bblock_link, link, link, &this->children) { > + assert(link->block == that); > + } > + foreach_list_typed (bblock_link, link, link, &that->parents) { > + assert(link->block == this); > + } > + > + this->end_ip = that->end_ip; > + this->end = that->end; > + this->else_block = that->else_block; > + > + this->cfg->remove_block(that); > +} > + > void > bblock_t::dump(backend_visitor *v) > { > diff --git a/src/mesa/drivers/dri/i965/brw_cfg.h > b/src/mesa/drivers/dri/i965/brw_cfg.h > index 9ffa7da..9f914cc 100644 > --- a/src/mesa/drivers/dri/i965/brw_cfg.h > +++ b/src/mesa/drivers/dri/i965/brw_cfg.h > @@ -60,6 +60,8 @@ struct bblock_t { > void add_successor(void *mem_ctx, bblock_t *successor); > bool is_predecessor_of(const bblock_t *block) const; > bool is_successor_of(const bblock_t *block) const; > + bool can_combine_with(const bblock_t *that) const; > + void combine_with(bblock_t *that); > void dump(backend_visitor *v); > #endif > > -- > 1.8.5.5 > > _______________________________________________ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev