glsl: Teach ir_variable_refcount about ir_loop::counter variables.
authorPaul Berry <stereotype441@gmail.com>
Tue, 26 Nov 2013 22:37:57 +0000 (14:37 -0800)
committerPaul Berry <stereotype441@gmail.com>
Sat, 30 Nov 2013 05:46:13 +0000 (21:46 -0800)
commit9d2951ea0acdcd219ad28831ac9e7112737d9ca3
tree1f2820bc641f55dd7d68dd27bd5a211a914e4625
parent1fb106527faa195197fa52e28e1b941c97e520c2
glsl: Teach ir_variable_refcount about ir_loop::counter variables.

If an ir_loop has a non-null "counter" field, the variable referred to
by this field is implicitly read and written by the loop.  We need to
account for this in ir_variable_refcount, otherwise there is a danger
we will try to dead-code-eliminate the loop counter variable.

Note: at the moment the dead code elimination bug doesn't occur due to
a bug in ir_hierarchical_visitor: it doesn't visit the "counter"
field, so dead code elimination doesn't treat it as a candidate for
elimination.  But the patch to follow will fix that bug, so we need to
fix ir_variable_refcount first in order to avoid breaking dead code
elimination.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/ir_variable_refcount.cpp
src/glsl/ir_variable_refcount.h