r300: copy propagate does not correctly account for control flow
This was spotted while testing with tests/spec/glsl-1.10/execution/vs-loop-complex-unroll-with-else-break.shader_test and loop unrolling disabled.
Vertex Program: after 'deadcode'
# Radeon Compiler Program
0: MOV temp[0].x, const[1].x___;
1: MOV temp[1], const[1].xxxy;
2: MOV temp[2], const[1].yyyy;
3: BGNLOOP;
4: SGE temp[3].x, temp[0].x___, const[0].x___;
5: IF temp[3].x___;
6: BRK;
7: ENDIF;
8: SLT temp[3].xy, const[1].yz__, temp[0].xx__;
9: MOV temp[4].x, temp[3].y___;
10: MOV temp[3].x, temp[3].x___;
11: IF temp[3].x___;
12: MOV temp[2], const[1].yxxy;
13: BRK;
14: ENDIF;
15: IF temp[4].x___;
16: MOV temp[2], const[1].xyxy;
17: BRK;
18: ENDIF;
19: SGE temp[3].x, temp[0].x___, const[1].z___;
20: MAD temp[5], -temp[3].xxxx, temp[1], temp[1];
21: MAD temp[1], temp[3].xxxx, const[1].xyxy, temp[5];
22: ADD temp[0].x, temp[0].x___, const[1].y___;
23: MOV temp[2], const[1].xyxy;
24: ENDLOOP;
25: ADD_SAT temp[0], temp[2], temp[1];
26: MOV output[0], input[0];
27: MOV output[1], temp[0];
Vertex Program: after 'dataflow optimize'
# Radeon Compiler Program
0: MOV temp[0].x, none.0___;
1: MOV temp[1], none.0001;
2: MOV temp[2], none.1111;
3: BGNLOOP;
4: SGE temp[3].x, temp[0].x___, const[0].x___;
5: IF temp[3].x___;
6: BRK;
7: ENDIF;
8: SLT temp[3].xy, const[1].1z__, temp[0].xx__;
9: IF temp[3].x___;
10: MOV temp[2], none.1001;
11: BRK;
12: ENDIF;
13: IF temp[3].y___;
14: MOV temp[2], none.0101;
15: BRK;
16: ENDIF;
17: SGE temp[3].x, temp[0].x___, const[1].z___;
18: MAD temp[5], -temp[3].xxxx, temp[1], temp[1];
19: MAD temp[1], temp[3].xxxx, none.0101, temp[5];
20: ADD temp[0].x, temp[0].x___, none.1___;
21: ENDLOOP;
22: ADD_SAT temp[0], none.0101, temp[1];
23: MOV output[0], input[0];
24: MOV output[1], temp[0];
The issue:
25: ADD_SAT temp[0], temp[2], temp[1];
was turned into
22: ADD_SAT temp[0], none.0101, temp[1];
even though
10: MOV temp[2], none.1001;
can happen on one if branch.
This doesn't pass even with RADEON_DEBUG=noopt because we have another bug in the predication logic.