From 1030ee6e9b0cc6c05a7f25c17c0cf722a6731c89 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Fri, 19 Sep 2014 16:42:10 -0700 Subject: [PATCH] i965/fs: A little harmless refactoring of register_coalesce Just pass the visitor into is_copy_payload() and is_coalesce_candidate() instead of a register size and the virtual_grf_sizes array. Among other things, this makes the code more obvious because you don't have to figure out where src_size came from. Signed-off-by: Jason Ekstrand Reviewed-by: Matt Turner --- .../drivers/dri/i965/brw_fs_register_coalesce.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) 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 318bfa610d4..73f18f9d62b 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_register_coalesce.cpp @@ -64,9 +64,9 @@ is_nop_mov(const fs_inst *inst) } static bool -is_copy_payload(const fs_inst *inst, int src_size) +is_copy_payload(const fs_visitor *v, const fs_inst *inst) { - if (src_size != inst->sources) + if (v->virtual_grf_sizes[inst->src[0].reg] != inst->regs_written) return false; const int reg = inst->src[0].reg; @@ -83,7 +83,7 @@ is_copy_payload(const fs_inst *inst, int src_size) } static bool -is_coalesce_candidate(const fs_inst *inst, const int *virtual_grf_sizes) +is_coalesce_candidate(const fs_visitor *v, const fs_inst *inst) { if ((inst->opcode != BRW_OPCODE_MOV && inst->opcode != SHADER_OPCODE_LOAD_PAYLOAD) || @@ -98,12 +98,12 @@ is_coalesce_candidate(const fs_inst *inst, const int *virtual_grf_sizes) return false; } - if (virtual_grf_sizes[inst->src[0].reg] > - virtual_grf_sizes[inst->dst.reg]) + if (v->virtual_grf_sizes[inst->src[0].reg] > + v->virtual_grf_sizes[inst->dst.reg]) return false; if (inst->opcode == SHADER_OPCODE_LOAD_PAYLOAD) { - if (!is_copy_payload(inst, virtual_grf_sizes[inst->src[0].reg])) { + if (!is_copy_payload(v, inst)) { return false; } } @@ -171,7 +171,7 @@ fs_visitor::register_coalesce() int var_from[MAX_SAMPLER_MESSAGE_SIZE]; foreach_block_and_inst(block, fs_inst, inst, cfg) { - if (!is_coalesce_candidate(inst, virtual_grf_sizes)) + if (!is_coalesce_candidate(this, inst)) continue; if (is_nop_mov(inst)) { -- 2.30.2