Commit Graph

8 Commits

Author SHA1 Message Date
Kenneth Graunke
0405bd08ca glsl: Don't trust loop analysis in the presence of function calls.
Function calls may have side effects that alter variables used inside
the loop.  In the fragment shader, they may even terminate the shader.
This means our analysis about loop-constant or induction variables may
be completely wrong.

In general it's impossible to determine whether they actually do or not
(due to the halting problem), so we'd need to perform conservative
static analysis.  For now, it's not worth the complexity: most functions
will be inlined, at which point we can unroll them successfully.

Fixes Piglit tests:
- shaders/glsl-fs-unroll-out-param
- shaders/glsl-fs-unroll-side-effect

NOTE: This is a candidate for release branches.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2012-04-02 14:15:19 -07:00
Kenneth Graunke
d3073f58c1 Convert everything from the talloc API to the ralloc API. 2011-01-31 10:17:09 -08:00
Eric Anholt
58c988ada5 glsl: Skip the rest of loop unrolling if no loops were found.
Shaves 1.6% (+/- 1.0%) off of ff_fragment_shader glean texCombine time
(n=5).
2011-01-18 10:17:37 -08:00
Eric Anholt
6929cdd14b glsl: Free the loop state context when we free the loop state.
Since this was talloced off of NULL instead of the compile state, it
was a real leak over the course of the program.  Noticed with
valgrind --leak-check=full --show-reachable=yes.  We should really
change these passes to generally get the compile context as an argument
so simple mistakes like this stop mattering.
2010-11-11 15:12:37 -08:00
Ian Romanick
956f049fd2 glsl2: Early return with visit_continue in loop_analysis::visit(ir_dereference_variable *)
Returning early with visit_continue_with_parent prevented the
then-statements and else-statements of if-statements such as the
following from being processed:

	  if (some_var) { ... } else { ... }

Fixes piglit test case glsl-fs-loop-nested-if and bugzilla #30030.
2010-09-07 13:36:32 -07:00
Ian Romanick
f061524f07 glsl2: Use as_constant some places instead of constant_expression_value
The places where constant_expression_value are still used in loop
analysis are places where a new expression tree is created and
constant folding won't have happened.  This is used, for example, when
we try to determine the maximal loop iteration count.

Based on review comments by Eric.  "...rely on constant folding to
have done its job, instead of going all through the subtree again when
it wasn't a constant."
2010-09-03 11:55:22 -07:00
Ian Romanick
3bcfafcf03 glsl2: Track the number of ir_loop_jump instructions that are in a loop 2010-09-03 11:55:22 -07:00
Ian Romanick
9434a0749f glsl2: Add module to analyze variables used in loops
This is the first step eventually leading to loop unrolling.
2010-09-03 11:55:21 -07:00