diff options
author | Matt Turner <mattst88@gmail.com> | 2014-07-15 15:29:29 -0700 |
---|---|---|
committer | Matt Turner <mattst88@gmail.com> | 2014-07-24 11:27:43 -0700 |
commit | ac2acf04f750a84fc6381b6efacfe1bbac61aa4d (patch) | |
tree | f211083c73cffe44f808a58d12d8d13fb082626c /src/mesa | |
parent | 0ddc28b026688df79e54d3af1d7914ff04b12fed (diff) | |
download | external_mesa3d-ac2acf04f750a84fc6381b6efacfe1bbac61aa4d.zip external_mesa3d-ac2acf04f750a84fc6381b6efacfe1bbac61aa4d.tar.gz external_mesa3d-ac2acf04f750a84fc6381b6efacfe1bbac61aa4d.tar.bz2 |
i965: Improve dead control flow elimination.
... to eliminate an ELSE instruction followed immediately by an ENDIF.
instructions in affected programs: 704 -> 700 (-0.57%)
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp b/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp index 14c6898..f0530a1 100644 --- a/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp +++ b/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp @@ -32,6 +32,7 @@ /* Look for and eliminate dead control flow: * * - if/endif + * . else in else/endif * - if/else/endif */ bool @@ -54,24 +55,28 @@ dead_control_flow_eliminate(backend_visitor *v) backend_instruction *if_inst = NULL, *else_inst = NULL; backend_instruction *prev_inst = (backend_instruction *) endif_inst->prev; - if (prev_inst->opcode == BRW_OPCODE_IF) { - if_inst = prev_inst; - found = true; - } else if (prev_inst->opcode == BRW_OPCODE_ELSE) { + if (prev_inst->opcode == BRW_OPCODE_ELSE) { else_inst = prev_inst; + found = true; prev_inst = (backend_instruction *) prev_inst->prev; - if (prev_inst->opcode == BRW_OPCODE_IF) { - if_inst = prev_inst; - found = true; - } + } + + if (prev_inst->opcode == BRW_OPCODE_IF) { + if_inst = prev_inst; + found = true; + } else { + /* Don't remove the ENDIF if we didn't find a dead IF. */ + endif_inst = NULL; } if (found) { - if_inst->remove(); + if (if_inst) + if_inst->remove(); if (else_inst) else_inst->remove(); - endif_inst->remove(); + if (endif_inst) + endif_inst->remove(); progress = true; } } |