From c7deee69ea6f64ea5b563985bf19d9deebe73b5b Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 24 Feb 2016 19:26:13 -0800 Subject: i965/cfg: Track prev_block and prev_inst explicitly in the whole function This provides a trivial simplification now, and it makes some future changes more straight forward. Signed-off-by: Ian Romanick Reviewed-by: Francisco Jerez --- src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp') 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 716e2bc25ba..7aa72b1b413 100644 --- a/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp +++ b/src/mesa/drivers/dri/i965/brw_dead_control_flow.cpp @@ -41,7 +41,9 @@ dead_control_flow_eliminate(backend_shader *s) bool progress = false; foreach_block_safe (block, s->cfg) { + bblock_t *prev_block = block->prev(); backend_instruction *const inst = block->start(); + backend_instruction *prev_inst = prev_block->end(); /* ENDIF instructions, by definition, can only be found at the start of * basic blocks. @@ -52,20 +54,20 @@ dead_control_flow_eliminate(backend_shader *s) backend_instruction *endif_inst = inst; backend_instruction *if_inst = NULL, *else_inst = NULL; - backend_instruction *prev_inst = endif_block->prev()->end(); if (prev_inst->opcode == BRW_OPCODE_ELSE) { else_inst = prev_inst; else_block = endif_block->prev(); found = true; - if (else_block->start_ip == else_block->end_ip) - prev_inst = else_block->prev()->end(); + if (else_block->start_ip == else_block->end_ip) { + prev_block = prev_block->prev(); + prev_inst = prev_block->end(); + } } if (prev_inst->opcode == BRW_OPCODE_IF) { if_inst = prev_inst; - if_block = else_block != NULL ? else_block->prev() - : endif_block->prev(); + if_block = prev_block; found = true; } else { /* Don't remove the ENDIF if we didn't find a dead IF. */ -- cgit v1.2.3