summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2014-10-28 20:12:21 -0700
committerMatt Turner <[email protected]>2014-12-01 16:42:13 -0800
commit60d507c3c5c7caed57119df0ab4d824ad1ea85dc (patch)
tree3ebe011a49ab74868eed3b78e8ed49872ef8eba2 /src/mesa/drivers/dri
parentbf8deb55146696b2332d9ea29f6242d236e1b46a (diff)
i965/fs: Dead code eliminate instructions writing the flag.
Most prominently helps Natural Selection 2, which has a surprising number shaders that do very complicated things before drawing black. instructions in affected programs: 21052 -> 16978 (-19.35%) Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp b/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp
index 9cf8d89eef4..fa471829e8e 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_dead_code_eliminate.cpp
@@ -43,15 +43,16 @@ fs_visitor::dead_code_eliminate()
int num_vars = live_intervals->num_vars;
BITSET_WORD *live = ralloc_array(NULL, BITSET_WORD, BITSET_WORDS(num_vars));
+ BITSET_WORD *flag_live = ralloc_array(NULL, BITSET_WORD, 1);
foreach_block (block, cfg) {
memcpy(live, live_intervals->block_data[block->num].liveout,
sizeof(BITSET_WORD) * BITSET_WORDS(num_vars));
+ memcpy(flag_live, live_intervals->block_data[block->num].flag_liveout,
+ sizeof(BITSET_WORD));
foreach_inst_in_block_reverse(fs_inst, inst, block) {
- if (inst->dst.file == GRF &&
- !inst->has_side_effects() &&
- !inst->writes_flag()) {
+ if (inst->dst.file == GRF && !inst->has_side_effects()) {
bool result_live = false;
if (inst->regs_written == 1) {
@@ -67,7 +68,7 @@ fs_visitor::dead_code_eliminate()
if (!result_live) {
progress = true;
- if (inst->writes_accumulator) {
+ if (inst->writes_accumulator || inst->writes_flag()) {
inst->dst = fs_reg(retype(brw_null_reg(), inst->dst.type));
} else {
inst->opcode = BRW_OPCODE_NOP;
@@ -76,6 +77,14 @@ fs_visitor::dead_code_eliminate()
}
}
+ if (inst->dst.is_null() && inst->writes_flag()) {
+ if (!BITSET_TEST(flag_live, inst->flag_subreg)) {
+ inst->opcode = BRW_OPCODE_NOP;
+ progress = true;
+ continue;
+ }
+ }
+
if (inst->dst.file == GRF) {
if (!inst->is_partial_write()) {
int var = live_intervals->var_from_reg(&inst->dst);
@@ -85,6 +94,10 @@ fs_visitor::dead_code_eliminate()
}
}
+ if (inst->writes_flag()) {
+ BITSET_CLEAR(flag_live, inst->flag_subreg);
+ }
+
for (int i = 0; i < inst->sources; i++) {
if (inst->src[i].file == GRF) {
int var = live_intervals->var_from_reg(&inst->src[i]);
@@ -94,10 +107,15 @@ fs_visitor::dead_code_eliminate()
}
}
}
+
+ if (inst->reads_flag()) {
+ BITSET_SET(flag_live, inst->flag_subreg);
+ }
}
}
ralloc_free(live);
+ ralloc_free(flag_live);
if (progress) {
foreach_block_and_inst_safe (block, backend_instruction, inst, cfg) {