From: Rhys Weatherley Date: Thu, 10 Jun 2004 05:20:05 +0000 (+0000) Subject: _jit_regs_load_value: avoid unnecessary spills if a temporary value X-Git-Tag: r.0.0.4~20 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=b995b50e66b97a28325fcbc6d76ba7e705ae9d35;p=francis%2Flibjit.git _jit_regs_load_value: avoid unnecessary spills if a temporary value won't be used again in the current block. --- diff --git a/ChangeLog b/ChangeLog index 002bf3a..7ef2e89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -28,6 +28,9 @@ register allocation on stacked parameters because it confuses the register spill logic. + * jit/jit-reg-alloc.c (_jit_regs_load_value): avoid unnecessary + spills if a temporary value won't be used again in the current block. + 2004-06-09 Rhys Weatherley * jit/jit-rules-arm.c (flush_constants): update the instruction diff --git a/jit/jit-reg-alloc.c b/jit/jit-reg-alloc.c index 7501190..1ae3d06 100644 --- a/jit/jit-reg-alloc.c +++ b/jit/jit-reg-alloc.c @@ -1050,6 +1050,18 @@ int _jit_regs_load_value } else { + if(gen->contents[reg].num_values == 1 && + (value->in_frame || value->in_global_register || !used_again)) + { + /* We are the only value in this register, and the + value is duplicated in the frame, or will never + be used again in this block. In this case, + we can disassociate the register from the value + and just return the register as-is */ + value->in_register = 0; + gen->contents[reg].num_values = 0; + gen->contents[reg].used_for_temp = 1; + } gen->contents[reg].age = gen->current_age; if(need_pair) { diff --git a/tutorial/t2.c b/tutorial/t2.c index 1160e2b..a4d67a2 100644 --- a/tutorial/t2.c +++ b/tutorial/t2.c @@ -90,7 +90,9 @@ int main(int argc, char **argv) jit_insn_return(function, temp4); /* Compile the function */ + jit_dump_function(stdout, function, "gcd"); jit_function_compile(function); + jit_dump_function(stdout, function, "gcd"); /* Unlock the context */ jit_context_build_end(context);