From 50b4508319cc5277d51a38065850eaa092afc0d4 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 18 Nov 2010 10:44:34 +0800 Subject: [PATCH] i965: Eliminate dead code more aggressively. If an instruction writes reg but nothing later uses it, then we don't need to bother doing it. Before, we were just killing code that was never read after it was ever written. This removes many interpolation instructions for attributes with only a few comopnents used. Improves nexuiz high-settings performance .46% +/- .12% (n=3) on my Ironlake. --- src/mesa/drivers/dri/i965/brw_fs.cpp | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index b12a4800410..ac795e0bda1 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -2801,26 +2801,17 @@ bool fs_visitor::dead_code_eliminate() { bool progress = false; - int num_vars = this->virtual_grf_next; - bool dead[num_vars]; - - for (int i = 0; i < num_vars; i++) { - dead[i] = this->virtual_grf_def[i] >= this->virtual_grf_use[i]; - - if (dead[i]) { - /* Mark off its interval so it won't interfere with anything. */ - this->virtual_grf_def[i] = -1; - this->virtual_grf_use[i] = -1; - } - } + int pc = 0; foreach_iter(exec_list_iterator, iter, this->instructions) { fs_inst *inst = (fs_inst *)iter.get(); - if (inst->dst.file == GRF && dead[inst->dst.reg]) { + if (inst->dst.file == GRF && this->virtual_grf_use[inst->dst.reg] <= pc) { inst->remove(); progress = true; } + + pc++; } return progress; -- 2.30.2