[Mesa-dev] [PATCH] i965: Fix JIP to properly skip over unrelated control flow.

Kenneth Graunke kenneth at whitecape.org
Thu Nov 19 19:49:02 PST 2015


On Thursday, November 19, 2015 02:05:44 PM Kenneth Graunke wrote:
> We've apparently always been botching JIP for sequences such as:
> 
>    do
>        cmp.f0.0 ...
>        (+f0.0) break
>        ...
>        if
>           ...
>        else
>           ...
>        endif
>        ...
>    while
> 
> Normally, UIP is supposed to point to the final destination of the jump,
> while in nested control flow, JIP is supposed to point to the end of the
> current nesting level.  It essentially bounces out of the current nested
> control flow, to an instruction that has a JIP which bounces out another
> level, and so on.
> 
> In the above example, when setting JIP for the BREAK, we call
> brw_find_next_block_end(), which begins a search after the BREAK for the
> next ENDIF, ELSE, WHILE, or HALT.  It ignores the IF and finds the ELSE,
> setting JIP there.
> 
> This makes no sense at all.  The break is supposed to skip over the
> whole if/else/endif block entirely.  They have a sibling relationship,
> not a nesting relationship.
> 
> This patch fixes brw_find_next_block_end() to track depth as it does
> its search, and ignore anything not at depth 0.  So when it sees the
> IF, it ignores everything until after the ENDIF.  That way, it finds
> the end of the right block.
> 
> Caught while debugging a tessellation shader - no apparent effect on
> Piglit.  I did look for actual applications that were affected, and
> found that GLBenchmark Manhattan had a BREAK with a bogus JIP.
> 
> Cc: mesa-stable at lists.freedesktop.org
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>

I tried pretty hard to produce a Piglit test that showed an actual
problem from doing this wrong - and I wasn't able to.

It seems it just steps through some extra instructions which do
nothing, and is pretty harmless.

So I don't think this should actually go to stable after all.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20151119/c6963bea/attachment.sig>


More information about the mesa-dev mailing list