glsl_to_tgsi: fix a bug in eliminate_dead_code_advanced()
The bug, reported to me by Vadim Girlin on IRC, was causing overzealous elimination of code in parallel if statements such as the following: if (x) { r = false; } if (y) { r = true; } Before this commit, the assignment inside the first if block would be misdetected as dead code and removed.
This commit is contained in:
parent
6cf7245f69
commit
20b0daf82d
|
@ -3514,25 +3514,23 @@ glsl_to_tgsi_visitor::eliminate_dead_code_advanced(void)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TGSI_OPCODE_ENDIF:
|
case TGSI_OPCODE_ENDIF:
|
||||||
--level;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TGSI_OPCODE_ELSE:
|
case TGSI_OPCODE_ELSE:
|
||||||
/* Clear all channels written inside the preceding if block from the
|
/* Promote the recorded level all channels written inside the preceding
|
||||||
* write array, but leave those that were not touched.
|
* if or else block to the level above the if/else block.
|
||||||
*
|
|
||||||
* FIXME: This destroys opportunities to remove dead code inside of
|
|
||||||
* IF blocks that are followed by an ELSE block.
|
|
||||||
*/
|
*/
|
||||||
for (int r = 0; r < this->next_temp; r++) {
|
for (int r = 0; r < this->next_temp; r++) {
|
||||||
for (int c = 0; c < 4; c++) {
|
for (int c = 0; c < 4; c++) {
|
||||||
if (!writes[4 * r + c])
|
if (!writes[4 * r + c])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (write_level[4 * r + c] >= level)
|
if (write_level[4 * r + c] == level)
|
||||||
writes[4 * r + c] = NULL;
|
write_level[4 * r + c] = level-1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(inst->op == TGSI_OPCODE_ENDIF)
|
||||||
|
--level;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TGSI_OPCODE_IF:
|
case TGSI_OPCODE_IF:
|
||||||
|
|
Loading…
Reference in New Issue