glsl: In lower_jumps.cpp, lower both branches of a conditional.
authorPaul Berry <stereotype441@gmail.com>
Fri, 1 Jul 2011 22:33:36 +0000 (15:33 -0700)
committerPaul Berry <stereotype441@gmail.com>
Fri, 8 Jul 2011 16:59:30 +0000 (09:59 -0700)
Previously, lower_jumps.cpp would break out of its loop after lowering
a jump instruction in just the then- or else-branch of a conditional,
and it would fail to lower a jump instruction occurring in the other
branch.

Without this patch, lower_jumps.cpp may require multiple passes in
order to lower all jumps.  This results in sub-optimal output because
lower_jumps.cpp produces a brand new set of temporary variables each
time it is run, and the redundant temporary variables are not
guaranteed to be eliminated by later optimization passes.

Fixes unit test test_lower_returns_4.

src/glsl/lower_jumps.cpp

index 199a0184fee0dc22bc07e10c2ad0f547c5780e01..07897825b4903d6dfd26b26b412808e8cf26edf3 100644 (file)
@@ -638,7 +638,10 @@ lower_continue:
             block_records[lower].min_strength = strength_always_clears_execute_flag;
             block_records[lower].may_clear_execute_flag = true;
             this->progress = true;
-            break;
+
+            /* Let the loop run again, in case the other branch of the
+             * if needs to be lowered too.
+             */
          }
       }