[Mesa-dev] [PATCH 6/6] glsl: Generate IR for switch statements

Dan McCabe zen3d.linux at gmail.com
Mon Jun 27 17:37:12 PDT 2011


On 06/27/2011 04:40 PM, Kenneth Graunke wrote:
> Here's another case that I'm not sure you're handling 
> correctly...conditional breaks:
>
> switch (expr) {
> case c0:
> case c1:
>     stmt0;
> case c2:
> case c3:
>     stmt1;
>     break;
> case c4:
>     stmt2;
>     if (foo)
>         break;
>     stmt3;        // happens if !foo
> case c5:
> default:
>     stmt4;        // happens if (expr != c4 || foo)
> };
>
> The easiest solution I can think of is to (in C++) track whether a 
> break -might- have been taken and emit a guard around further statements:
>
> stmt2;
> if (foo)
>    has_break_tmp = true; // hit the break statement
>
> if (has_break_tmp) { // could have potentially hit "break", must check
>     stmt3;
> }

This is similar to the proposal that I floated Fri PM and that you 
commented upon at 17:15  today.

Please correct me if I'm wrong.

cheers, danm



More information about the mesa-dev mailing list