[Mesa-dev] glsl: Improvements to lower_jumps.cpp

Paul Berry stereotype441 at gmail.com
Tue Jul 5 15:07:21 PDT 2011

The following patch series fixes bug #36669 (EmitNoMainReturn set
to 1 doesn't make the GLSL compiler lower all the RET opcodes) as
well as several other bugs I found in the course of reviewing
lower_jumps.cpp.  Some of these bugs prevented certain jumps from
ever being lowered, or produced assertion failures.  Others
merely caused sub-optimal GPU code to be generated, by forcing
do_lower_jumps() to take multiple passes in order to lower all

The optimization performed by lower_jumps.cpp is quite complex
and has a number of subtle corner cases.  In order to be
confident that these changes were correct, I added unit tests
that verify its operation in isolation.  I'm particularly
interested to hear comments on how the tests are structured.  I'm
not aware of unit tests having been used in the mesa project
before, and I'd like to find a way that we can make unit testing
easier to do in other parts of the project (e.g. other
optimization passes).

The unit tests are written in Python, and may be found in
src/glsl/testing.  They make use of a new stand-alone executable,
glsl_test, to invoke the jump lowering optimization in isolation.
They may be run using "make check".

The unit tests, and the glsl_test executable they rely on, are
build-time artifacts only.  They do not affect what is installed
on the user's system by "make install".

[PATCH 01/11] glsl: Remove unused function prototypes.
[PATCH 02/11] glsl: Make ir_reader able to read plain (return) statements.
[PATCH 03/11] glsl: Create a standalone executable for testing optimization passes.
[PATCH 04/11] glsl: Add a unit test for lower_jumps.cpp
[PATCH 05/11] glsl: Add explanatory comments to lower_jumps.cpp.
[PATCH 06/11] glsl: Refactor logic for determining whether to lower return statements.
[PATCH 07/11] glsl: Lower unconditional return statements.
[PATCH 08/11] glsl: lower unconditional returns and continues in loops.
[PATCH 09/11] glsl: Use foreach_list in lower_jumps.cpp
[PATCH 10/11] glsl: In lower_jumps.cpp, lower both branches of a conditional.
[PATCH 11/11] glsl: Lower break instructions when necessary at the end of a loop.

More information about the mesa-dev mailing list