[Mesa-dev] [PATCH 16/20] i965/cfg: Add functions to combine basic blocks.

Matt Turner mattst88 at gmail.com
Tue Aug 19 11:39:06 PDT 2014


On Tue, Aug 19, 2014 at 12:53 AM, Pohjolainen, Topi
<topi.pohjolainen at intel.com> wrote:
> 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...

Oh, I wrote that comment when I was trying to decide how to write this
function. I should have removed it. Sorry about the confusion.

Yes, exactly right that 'that' is merged into 'this'.


More information about the mesa-dev mailing list