summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-04-01 15:38:23 -0700
committerJason Ekstrand <[email protected]>2015-05-06 10:29:30 -0700
commit32af7d4188e286a525081ada9965070dd41dbab7 (patch)
tree9169a9b13b17333c526f4e575608140b54118dad /src/mesa/drivers
parent76c1086f2dfb37a1edf6d2df6eebbe11ccbfc50b (diff)
i965/fs_inst: Add an is_copy_payload helper
This commit adds a new is_copy_payload helper to fs_inst that takes the place of the similarly named functions in cse and register coalesce. The two is_copy_payload functions in CSE and register coalesce were subtly different and potentially subtly broken. The new version unifies the two and should be more correct. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.cpp20
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_cse.cpp22
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp17
-rw-r--r--src/mesa/drivers/dri/i965/brw_ir_fs.h1
4 files changed, 25 insertions, 35 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 22223e11f5c..2a38854dbde 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -521,6 +521,26 @@ fs_inst::is_send_from_grf() const
}
bool
+fs_inst::is_copy_payload(const brw::simple_allocator &grf_alloc) const
+{
+ if (this->opcode != SHADER_OPCODE_LOAD_PAYLOAD)
+ return false;
+
+ fs_reg reg = this->src[0];
+ if (reg.file != GRF || reg.reg_offset != 0 || reg.stride == 0)
+ return false;
+
+ if (grf_alloc.sizes[reg.reg] != this->regs_written)
+ return false;
+
+ for (int i = 1; i < this->sources; i++)
+ if (!this->src[i].equals(::offset(reg, i)))
+ return false;
+
+ return true;
+}
+
+bool
fs_inst::can_do_source_mods(const struct brw_device_info *devinfo)
{
if (devinfo->gen == 6 && is_math())
diff --git a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
index ad38475d834..fc19e0f38f2 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_cse.cpp
@@ -43,23 +43,7 @@ struct aeb_entry : public exec_node {
}
static bool
-is_copy_payload(const fs_inst *inst)
-{
- const int reg = inst->src[0].reg;
- if (inst->src[0].reg_offset != 0)
- return false;
-
- for (int i = 1; i < inst->sources; i++) {
- if (inst->src[i].reg != reg ||
- inst->src[i].reg_offset != i) {
- return false;
- }
- }
- return true;
-}
-
-static bool
-is_expression(const fs_inst *const inst)
+is_expression(const fs_visitor *v, const fs_inst *const inst)
{
switch (inst->opcode) {
case BRW_OPCODE_MOV:
@@ -104,7 +88,7 @@ is_expression(const fs_inst *const inst)
case SHADER_OPCODE_COS:
return inst->mlen < 2;
case SHADER_OPCODE_LOAD_PAYLOAD:
- return !is_copy_payload(inst);
+ return !inst->is_copy_payload(v->alloc);
default:
return inst->is_send_from_grf() && !inst->has_side_effects();
}
@@ -219,7 +203,7 @@ fs_visitor::opt_cse_local(bblock_t *block)
int ip = block->start_ip;
foreach_inst_in_block(fs_inst, inst, block) {
/* Skip some cases. */
- if (is_expression(inst) && !inst->is_partial_write() &&
+ if (is_expression(this, inst) && !inst->is_partial_write() &&
(inst->dst.file != HW_REG || inst->dst.is_null()))
{
bool found = false;
diff --git a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
index 09f0faddbdb..2ad7079bdf8 100644
--- a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp
@@ -64,21 +64,6 @@ is_nop_mov(const fs_inst *inst)
}
static bool
-is_copy_payload(const fs_visitor *v, const fs_inst *inst)
-{
- if (v->alloc.sizes[inst->src[0].reg] != inst->regs_written)
- return false;
-
- fs_reg reg = inst->src[0];
-
- for (int i = 0; i < inst->sources; i++)
- if (!inst->src[i].equals(offset(reg, i)))
- return false;
-
- return true;
-}
-
-static bool
is_coalesce_candidate(const fs_visitor *v, const fs_inst *inst)
{
if ((inst->opcode != BRW_OPCODE_MOV &&
@@ -99,7 +84,7 @@ is_coalesce_candidate(const fs_visitor *v, const fs_inst *inst)
return false;
if (inst->opcode == SHADER_OPCODE_LOAD_PAYLOAD) {
- if (!is_copy_payload(v, inst)) {
+ if (!inst->is_copy_payload(v->alloc)) {
return false;
}
}
diff --git a/src/mesa/drivers/dri/i965/brw_ir_fs.h b/src/mesa/drivers/dri/i965/brw_ir_fs.h
index 9ebe9808dda..1e3d2b4a315 100644
--- a/src/mesa/drivers/dri/i965/brw_ir_fs.h
+++ b/src/mesa/drivers/dri/i965/brw_ir_fs.h
@@ -241,6 +241,7 @@ public:
bool overwrites_reg(const fs_reg &reg) const;
bool is_send_from_grf() const;
bool is_partial_write() const;
+ bool is_copy_payload(const brw::simple_allocator &grf_alloc) const;
int regs_read(int arg) const;
bool can_do_source_mods(const struct brw_device_info *devinfo);
bool has_side_effects() const;