Mesa (master): i965/fs: Move copy propagation test out to a separate function.
Eric Anholt
anholt at kemper.freedesktop.org
Tue Jul 3 20:00:24 UTC 2012
Module: Mesa
Branch: master
Commit: 458f7f014139deb48a4cf0a9e6bdca3a57d24208
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=458f7f014139deb48a4cf0a9e6bdca3a57d24208
Author: Eric Anholt <eric at anholt.net>
Date: Wed Jun 6 10:57:54 2012 -0700
i965/fs: Move copy propagation test out to a separate function.
It's going to get more complicated in a moment.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
---
src/mesa/drivers/dri/i965/brw_fs.h | 4 +++
.../drivers/dri/i965/brw_fs_copy_propagation.cpp | 22 ++++++++++++++-----
2 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h
index ee06732..507a637 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_fs.h
@@ -50,6 +50,9 @@ extern "C" {
#include "glsl/ir.h"
class fs_bblock;
+namespace {
+ class acp_entry;
+}
enum register_file {
BAD_FILE,
@@ -492,6 +495,7 @@ public:
bool opt_cse();
bool opt_cse_local(fs_bblock *block, exec_list *aeb);
bool opt_copy_propagate();
+ bool try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry);
bool opt_copy_propagate_local(void *mem_ctx, fs_bblock *block,
exec_list *acp);
bool register_coalesce();
diff --git a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
index 2396051..d510e5b 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_copy_propagation.cpp
@@ -31,6 +31,21 @@ struct acp_entry : public exec_node {
};
}
+bool
+fs_visitor::try_copy_propagate(fs_inst *inst, int arg, acp_entry *entry)
+{
+ if (inst->src[arg].file != entry->dst.file ||
+ inst->src[arg].reg != entry->dst.reg ||
+ inst->src[arg].reg_offset != entry->dst.reg_offset) {
+ return false;
+ }
+
+ inst->src[arg].reg = entry->src.reg;
+ inst->src[arg].reg_offset = entry->src.reg_offset;
+
+ return true;
+}
+
/** @file brw_fs_copy_propagation.cpp
*
* Support for local copy propagation by walking the list of instructions
@@ -58,13 +73,8 @@ fs_visitor::opt_copy_propagate_local(void *mem_ctx,
acp_entry *entry = (acp_entry *)entry_node;
for (int i = 0; i < 3; i++) {
- if (inst->src[i].file == entry->dst.file &&
- inst->src[i].reg == entry->dst.reg &&
- inst->src[i].reg_offset == entry->dst.reg_offset) {
- inst->src[i].reg = entry->src.reg;
- inst->src[i].reg_offset = entry->src.reg_offset;
+ if (try_copy_propagate(inst, i, entry))
progress = true;
- }
}
}
More information about the mesa-commit
mailing list