glsl2: Eliminate zero-iteration loops

This commit is contained in:
Ian Romanick
2010-08-27 11:26:08 -07:00
parent 8df2dbf91d
commit 7850ce0a99
+7 -1
View File
@@ -234,7 +234,7 @@ loop_control_visitor::visit_leave(ir_loop *ir)
const int iterations = calculate_iterations(init, limit,
lv->increment,
cmp);
if (iterations > 0) {
if (iterations >= 0) {
/* If the new iteration count is lower than the previously
* believed iteration count, update the loop control values.
*/
@@ -267,6 +267,12 @@ loop_control_visitor::visit_leave(ir_loop *ir)
}
}
/* If we have proven the one of the loop exit conditions is satisifed before
* running the loop once, remove the loop.
*/
if (max_iterations == 0)
ir->remove();
return visit_continue;
}