glsl: Add an optimization pass to flatten simple nested if blocks.
GLBenchmark 2.7's shaders contain conditional blocks like: if (x) { if (y) { ... } } where the outer conditional's then clause contains exactly one statement (the nested if) and there are no else clauses. This can easily be optimized into: if (x && y) { ... } This saves a few instructions in GLBenchmark 2.7: total instructions in shared programs: 11833 -> 11649 (-1.55%) instructions in affected programs: 8234 -> 8050 (-2.23%) It also helps CS:GO slightly (-0.05%/-0.22%). More importantly, however, it simplifies the control flow graph, which could enable other optimizations. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net>
This commit is contained in:
@@ -82,6 +82,7 @@ bool do_function_inlining(exec_list *instructions);
|
||||
bool do_lower_jumps(exec_list *instructions, bool pull_out_jumps = true, bool lower_sub_return = true, bool lower_main_return = false, bool lower_continue = false, bool lower_break = false);
|
||||
bool do_lower_texture_projection(exec_list *instructions);
|
||||
bool do_if_simplification(exec_list *instructions);
|
||||
bool opt_flatten_nested_if_blocks(exec_list *instructions);
|
||||
bool do_discard_simplification(exec_list *instructions);
|
||||
bool lower_if_to_cond_assign(exec_list *instructions, unsigned max_depth = 0);
|
||||
bool do_mat_op_to_vec(exec_list *instructions);
|
||||
|
Reference in New Issue
Block a user