diff options
author | Ian Romanick <ian.d.romanick@intel.com> | 2010-08-27 11:26:08 -0700 |
---|---|---|
committer | Ian Romanick <ian.d.romanick@intel.com> | 2010-09-03 11:55:21 -0700 |
commit | 7850ce0a9990c7f752e43a1dd88c204a7cf090aa (patch) | |
tree | 3154778768f146e2c5474c520fc3e394b95c4066 /src/glsl/loop_controls.cpp | |
parent | 8df2dbf91ddfd0c1590e33015e85470b67e69319 (diff) | |
download | external_mesa3d-7850ce0a9990c7f752e43a1dd88c204a7cf090aa.zip external_mesa3d-7850ce0a9990c7f752e43a1dd88c204a7cf090aa.tar.gz external_mesa3d-7850ce0a9990c7f752e43a1dd88c204a7cf090aa.tar.bz2 |
glsl2: Eliminate zero-iteration loops
Diffstat (limited to 'src/glsl/loop_controls.cpp')
-rw-r--r-- | src/glsl/loop_controls.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/glsl/loop_controls.cpp b/src/glsl/loop_controls.cpp index 2eddb91..9eb1a89 100644 --- a/src/glsl/loop_controls.cpp +++ b/src/glsl/loop_controls.cpp @@ -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; } |