[Mesa-dev] [PATCH 06/10] i965: Don't dead-code eliminate instructions that write to the accumulator.
Matt Turner
mattst88 at gmail.com
Mon Sep 23 16:13:03 PDT 2013
---
I've noticed that the vec4 backend doesn't use the ARF register file. Is this
because we decided that it's not necessary and we can just use HW_REG?
So, this patch will probably need a fixup.
src/mesa/drivers/dri/i965/brw_fs.cpp | 16 +++++++++++++++-
src/mesa/drivers/dri/i965/brw_vec4.cpp | 16 +++++++++++++++-
2 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index d193d44..6dc37ea 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -1845,7 +1845,21 @@ fs_visitor::dead_code_eliminate()
if (inst->dst.file == GRF) {
assert(this->virtual_grf_end[inst->dst.reg] >= pc);
if (this->virtual_grf_end[inst->dst.reg] == pc) {
- inst->remove();
+ /* Don't dead code eliminate instructions that write to the
+ * accumulator as a side-effect. Instead just set the destination
+ * to the null register to free it.
+ */
+ switch (inst->opcode) {
+ case BRW_OPCODE_ADDC:
+ case BRW_OPCODE_SUBB:
+ case BRW_OPCODE_MACH:
+ inst->dst.file = ARF;
+ inst->dst.reg = BRW_ARF_NULL;
+ break;
+ default:
+ inst->remove();
+ break;
+ }
progress = true;
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_vec4.cpp b/src/mesa/drivers/dri/i965/brw_vec4.cpp
index 2c1f541..6a3285a 100644
--- a/src/mesa/drivers/dri/i965/brw_vec4.cpp
+++ b/src/mesa/drivers/dri/i965/brw_vec4.cpp
@@ -313,7 +313,21 @@ vec4_visitor::dead_code_eliminate()
if (inst->dst.file == GRF) {
assert(this->virtual_grf_end[inst->dst.reg] >= pc);
if (this->virtual_grf_end[inst->dst.reg] == pc) {
- inst->remove();
+ /* Don't dead code eliminate instructions that write to the
+ * accumulator as a side-effect. Instead just set the destination
+ * to the null register to free it.
+ */
+ switch (inst->opcode) {
+ case BRW_OPCODE_ADDC:
+ case BRW_OPCODE_SUBB:
+ case BRW_OPCODE_MACH:
+ inst->dst.file = ARF;
+ inst->dst.reg = BRW_ARF_NULL;
+ break;
+ default:
+ inst->remove();
+ break;
+ }
progress = true;
}
}
--
1.8.3.2
More information about the mesa-dev
mailing list