Remove dead code assignments and variable declarations.

This pass only works on assignments where the variable is never
referenced.  There is no code flow analysis, so it can't do a better
job of avoiding redundant assignments.

For now, the optimizer only does do_dead_code_unlinked(), so it won't
trim the builtin variable list or initializers outside of the scope of
functions.  This is because we don't have the visibility into other
functions that might get linked in in order to eliminate work on
global variables.
This commit is contained in:
Eric Anholt
2010-04-16 16:43:47 -07:00
parent 71df19f5ef
commit 7d21104a8b
5 changed files with 383 additions and 0 deletions
+2
View File
@@ -35,6 +35,7 @@
#include "glsl_parser_extras.h"
#include "glsl_parser.h"
#include "ir_constant_folding.h"
#include "ir_dead_code.h"
#include "ir_function_inlining.h"
#include "ir_if_simplification.h"
#include "ir_print_visitor.h"
@@ -761,6 +762,7 @@ main(int argc, char **argv)
progress = do_function_inlining(&instructions) || progress;
progress = do_if_simplification(&instructions) || progress;
progress = do_dead_code_unlinked(&instructions) || progress;
/* Constant folding */
ir_constant_folding_visitor constant_folding;