[Mesa-dev] [PATCH] nir: allow stitching of non-empty block

Ian Romanick idr at freedesktop.org
Fri Feb 8 18:29:07 UTC 2019


On 2/8/19 5:21 AM, Juan A. Suarez Romero wrote:
> On Sat, 2019-01-26 at 08:37 -0800, Jason Ekstrand wrote:
>> This makes me a bit nervous. I'll have to look at it in more detail.
>>
> 
> Did you have time to take a look at this?

Is there a test case that hits this?  Was it found by inspection?  I'm
curious what the back story is...

> 	J.A.
> 
>> On January 25, 2019 09:37:52 "Juan A. Suarez Romero" <jasuarez at igalia.com> 
>> wrote:
>>
>>> When stitching two blocks A and B, where A's last instruction is a jump,
>>> it is not required that B is empty; it can be plainly removed.
>>>
>>> This can happen in a situation like this:
>>>
>>> vec1 1 ssa_1 = load_const (true)
>>> vec1 1 ssa_2 = load_const (false)
>>> block block_1:
>>> [...]
>>> loop {
>>>  vec1 ssa_3 = phi block_1: ssa_2, block_4: ssa_1
>>>  if ssa_3 {
>>>    block block_2:
>>>    [...]
>>>    break
>>>  } else {
>>>    block block_3:
>>>  }
>>>  vec1 ssa_4 = <alu operation>
>>>  if ssa_4 {
>>>    block block_4:
>>>    continue
>>>  } else {
>>>    block block_5:
>>>  }
>>>  block block_6:
>>>  [...]
>>> }
>>>
>>> And opt_peel_loop_initial_if is applied. In this case, we would be
>>> ending up stitching block_2 (which finalizes with a jump) with
>>> block_4, which is not empty.
>>>
>>> CC: Jason Ekstrand <jason at jlekstrand.net>
>>> ---
>>> src/compiler/nir/nir_control_flow.c | 1 -
>>> 1 file changed, 1 deletion(-)
>>>
>>> diff --git a/src/compiler/nir/nir_control_flow.c 
>>> b/src/compiler/nir/nir_control_flow.c
>>> index ddba2e55b45..27508f230d6 100644
>>> --- a/src/compiler/nir/nir_control_flow.c
>>> +++ b/src/compiler/nir/nir_control_flow.c
>>> @@ -550,7 +550,6 @@ stitch_blocks(nir_block *before, nir_block *after)
>>>     */
>>>
>>>    if (nir_block_ends_in_jump(before)) {
>>> -      assert(exec_list_is_empty(&after->instr_list));
>>>       if (after->successors[0])
>>>          remove_phi_src(after->successors[0], after);
>>>       if (after->successors[1])
>>> --
>>> 2.20.1
>>
>>
>>
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list