From: Matt Turner Date: Wed, 16 Jul 2014 22:20:15 +0000 (-0700) Subject: i965/cfg: Point to bblock_t containing associated control flow X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5e6ead5e8b0a79dce63f741dfca8328b7d4020f9;p=mesa.git i965/cfg: Point to bblock_t containing associated control flow ... rather than pointing directly to the associated instruction. This will let us set the block containing the IF statement's else-pointer to NULL, when we delete a useless ELSE instruction, as in the case (+f0) if(8) ... else(8) endif(8) Also, remove the pointer to the ENDIF, since it's unused, and it was also potentially wrong, in the case of a basic block containing both an ENDIF and an IF instruction: endif(8) cmp.ne.f0(8) ... (+f0) if(8) Reviewed-by: Topi Pohjolainen --- diff --git a/src/mesa/drivers/dri/i965/brw_cfg.cpp b/src/mesa/drivers/dri/i965/brw_cfg.cpp index c39edad51c4..3895469b055 100644 --- a/src/mesa/drivers/dri/i965/brw_cfg.cpp +++ b/src/mesa/drivers/dri/i965/brw_cfg.cpp @@ -51,17 +51,14 @@ link(void *mem_ctx, bblock_t *block) } bblock_t::bblock_t(cfg_t *cfg) : - cfg(cfg), start_ip(0), end_ip(0), num(0) + cfg(cfg), start_ip(0), end_ip(0), num(0), + if_block(NULL), else_block(NULL) { start = NULL; end = NULL; parents.make_empty(); children.make_empty(); - - if_inst = NULL; - else_inst = NULL; - endif_inst = NULL; } void @@ -183,32 +180,25 @@ cfg_t::cfg_t(exec_list *instructions) set_next_block(&cur, cur_endif, ip - 1); } - backend_instruction *else_inst = NULL; if (cur_else) { - else_inst = (backend_instruction *)cur_else->end; - cur_else->add_successor(mem_ctx, cur_endif); } else { cur_if->add_successor(mem_ctx, cur_endif); } assert(cur_if->end->opcode == BRW_OPCODE_IF); - assert(!else_inst || else_inst->opcode == BRW_OPCODE_ELSE); - assert(inst->opcode == BRW_OPCODE_ENDIF); + assert(!cur_else || cur_else->end->opcode == BRW_OPCODE_ELSE); - cur_if->if_inst = cur_if->end; - cur_if->else_inst = else_inst; - cur_if->endif_inst = inst; + cur_if->if_block = cur_if; + cur_if->else_block = cur_else; if (cur_else) { - cur_else->if_inst = cur_if->end; - cur_else->else_inst = else_inst; - cur_else->endif_inst = inst; + cur_else->if_block = cur_if; + cur_else->else_block = cur_else; } - cur->if_inst = cur_if->end; - cur->else_inst = else_inst; - cur->endif_inst = inst; + cur->if_block = cur_if; + cur->else_block = cur_else; /* Pop the stack so we're in the previous if/else/endif */ cur_if = pop_stack(&if_stack); diff --git a/src/mesa/drivers/dri/i965/brw_cfg.h b/src/mesa/drivers/dri/i965/brw_cfg.h index d6e11050ff9..ecbb996244e 100644 --- a/src/mesa/drivers/dri/i965/brw_cfg.h +++ b/src/mesa/drivers/dri/i965/brw_cfg.h @@ -76,15 +76,13 @@ struct bblock_t { struct exec_list children; int num; - /* If the current basic block ends in an IF, ELSE, or ENDIF instruction, - * these pointers will hold the locations of the other associated control - * flow instructions. + /* If the current basic block ends in an IF or ELSE instruction, these will + * point to the basic blocks containing the other associated instruction. * * Otherwise they are NULL. */ - struct backend_instruction *if_inst; - struct backend_instruction *else_inst; - struct backend_instruction *endif_inst; + struct bblock_t *if_block; + struct bblock_t *else_block; }; struct cfg_t { diff --git a/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp b/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp index 5c79296f5a8..d64cd98343a 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_sel_peephole.cpp @@ -137,10 +137,10 @@ fs_visitor::opt_peephole_sel() if (if_inst->opcode != BRW_OPCODE_IF) continue; - if (!block->else_inst) + if (!block->else_block) continue; - fs_inst *else_inst = (fs_inst *) block->else_inst; + fs_inst *else_inst = (fs_inst *) block->else_block->end; assert(else_inst->opcode == BRW_OPCODE_ELSE); fs_inst *else_mov[MAX_MOVS] = { NULL };