From 8113b81593ebe9f9ebe645e8f43100e8999921f3 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 2 Jun 2004 10:18:55 +0000 Subject: [PATCH] Recognise "t = a op b; a = t" and turn it into "a = a op b" to make it easier for back ends to recognise special idioms such as increments and decrements. --- ChangeLog | 4 ++++ jit/jit-insn.c | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5f974f5..b7c3d13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,10 @@ global register and it is not going to be destroyed by an instruction, then use the global register as the operand. + * jit/jit-insn.c: recognise "t = a op b; a = t" and turn it + into "a = a op b" to make it easier for back ends to recognise + special idioms such as increments and decrements. + 2004-06-01 Rhys Weatherley * jit/jit-cache.c, jit/jit-elf-read.c, tools/gen-apply.c: diff --git a/jit/jit-insn.c b/jit/jit-insn.c index 3c83e4d..4df7765 100644 --- a/jit/jit-insn.c +++ b/jit/jit-insn.c @@ -1416,6 +1416,15 @@ int jit_insn_store(jit_function_t func, jit_value_t dest, jit_value_t value) { return 0; } + insn = _jit_block_get_last(func->builder->current_block); + if(value->is_temporary && insn && insn->dest == value && + insn->value1 == dest) + { + /* Special case: we can move the destination value back into + the previous instruction, to avoid a redundant copy */ + insn->dest = dest; + return 1; + } insn = _jit_block_add_insn(func->builder->current_block); if(!insn) { -- 2.47.3