From c4b837a548feba8c29d43ed7243cb0f35f3b250d Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 26 Sep 2014 16:32:25 +0200 Subject: [PATCH] opcode: mark copy opcodes and don't emit mov for them There is no need to emit a mov operation when the source and dest registers of a copy operation are different, that's kindof the point of the copy operation. Saves some useless movs whenever copyX is used. --- orc/orcopcode.h | 1 + orc/orcopcodes.c | 8 ++++---- orc/orcprogram-sse.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/orc/orcopcode.h b/orc/orcopcode.h index e209f98..63310c9 100644 --- a/orc/orcopcode.h +++ b/orc/orcopcode.h @@ -34,6 +34,7 @@ struct _OrcOpcodeSet { #define ORC_STATIC_OPCODE_STORE (1<<5) #define ORC_STATIC_OPCODE_INVARIANT (1<<6) #define ORC_STATIC_OPCODE_ITERATOR (1<<7) +#define ORC_STATIC_OPCODE_COPY (1<<8) struct _OrcStaticOpcode { diff --git a/orc/orcopcodes.c b/orc/orcopcodes.c index eda8610..820f0c9 100644 --- a/orc/orcopcodes.c +++ b/orc/orcopcodes.c @@ -296,7 +296,7 @@ static OrcStaticOpcode opcodes[] = { { "avgub", 0, { 1 }, { 1, 1 }, emulate_avgub }, { "cmpeqb", 0, { 1 }, { 1, 1 }, emulate_cmpeqb }, { "cmpgtsb", 0, { 1 }, { 1, 1 }, emulate_cmpgtsb }, - { "copyb", 0, { 1 }, { 1 }, emulate_copyb }, + { "copyb", ORC_STATIC_OPCODE_COPY, { 1 }, { 1 }, emulate_copyb }, { "loadb", ORC_STATIC_OPCODE_LOAD, { 1 }, { 1 }, emulate_loadb }, { "loadoffb", ORC_STATIC_OPCODE_LOAD|ORC_STATIC_OPCODE_SCALAR, { 1 }, { 1, 4 }, emulate_loadoffb }, { "loadupdb", ORC_STATIC_OPCODE_LOAD|ORC_STATIC_OPCODE_ITERATOR, { 1 }, { 1 }, emulate_loadupdb }, @@ -335,7 +335,7 @@ static OrcStaticOpcode opcodes[] = { { "avguw", 0, { 2 }, { 2, 2 }, emulate_avguw }, { "cmpeqw", 0, { 2 }, { 2, 2 }, emulate_cmpeqw }, { "cmpgtsw", 0, { 2 }, { 2, 2 }, emulate_cmpgtsw }, - { "copyw", 0, { 2 }, { 2 }, emulate_copyw }, + { "copyw", ORC_STATIC_OPCODE_COPY, { 2 }, { 2 }, emulate_copyw }, { "div255w", 0, { 2 }, { 2 }, emulate_div255w }, { "divluw", 0, { 2 }, { 2, 2 }, emulate_divluw }, { "loadw", ORC_STATIC_OPCODE_LOAD, { 2 }, { 2 }, emulate_loadw }, @@ -370,7 +370,7 @@ static OrcStaticOpcode opcodes[] = { { "avgul", 0, { 4 }, { 4, 4 }, emulate_avgul }, { "cmpeql", 0, { 4 }, { 4, 4 }, emulate_cmpeql }, { "cmpgtsl", 0, { 4 }, { 4, 4 }, emulate_cmpgtsl }, - { "copyl", 0, { 4 }, { 4 }, emulate_copyl }, + { "copyl", ORC_STATIC_OPCODE_COPY, { 4 }, { 4 }, emulate_copyl }, { "loadl", ORC_STATIC_OPCODE_LOAD, { 4 }, { 4 }, emulate_loadl }, { "loadoffl", ORC_STATIC_OPCODE_LOAD|ORC_STATIC_OPCODE_SCALAR, { 4 }, { 4, 4 }, emulate_loadoffl }, { "loadpl", ORC_STATIC_OPCODE_LOAD|ORC_STATIC_OPCODE_SCALAR|ORC_STATIC_OPCODE_INVARIANT, { 4 }, { 4 }, emulate_loadpl }, @@ -396,7 +396,7 @@ static OrcStaticOpcode opcodes[] = { { "loadpq", ORC_STATIC_OPCODE_LOAD|ORC_STATIC_OPCODE_SCALAR|ORC_STATIC_OPCODE_INVARIANT, { 8 }, { 8 }, emulate_loadpq }, { "storeq", ORC_STATIC_OPCODE_STORE, { 8 }, { 8 }, emulate_storeq }, { "splatw3q", 0, { 8 }, { 8 }, emulate_splatw3q }, - { "copyq", 0, { 8 }, { 8 }, emulate_copyq }, + { "copyq", ORC_STATIC_OPCODE_COPY, { 8 }, { 8 }, emulate_copyq }, { "cmpeqq", 0, { 8 }, { 8, 8 }, emulate_cmpeqq }, { "cmpgtsq", 0, { 8 }, { 8, 8 }, emulate_cmpgtsq }, { "andq", 0, { 8 }, { 8, 8 }, emulate_andq }, diff --git a/orc/orcprogram-sse.c b/orc/orcprogram-sse.c index abeeff5..51c1536 100644 --- a/orc/orcprogram-sse.c +++ b/orc/orcprogram-sse.c @@ -1029,7 +1029,7 @@ orc_sse_emit_loop (OrcCompiler *compiler, int offset, int update) rule = insn->rule; if (rule && rule->emit) { - if (!(insn->opcode->flags & (ORC_STATIC_OPCODE_ACCUMULATOR|ORC_STATIC_OPCODE_LOAD|ORC_STATIC_OPCODE_STORE)) && + if (!(insn->opcode->flags & (ORC_STATIC_OPCODE_ACCUMULATOR|ORC_STATIC_OPCODE_LOAD|ORC_STATIC_OPCODE_STORE|ORC_STATIC_OPCODE_COPY)) && compiler->vars[insn->dest_args[0]].alloc != compiler->vars[insn->src_args[0]].alloc) { #ifdef MMX -- 2.7.4