]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
_jit_regs_load_value: avoid unnecessary spills if a temporary value
authorRhys Weatherley <rweather@southern-storm.com.au>
Thu, 10 Jun 2004 05:20:05 +0000 (05:20 +0000)
committerRhys Weatherley <rweather@southern-storm.com.au>
Thu, 10 Jun 2004 05:20:05 +0000 (05:20 +0000)
won't be used again in the current block.

ChangeLog
jit/jit-reg-alloc.c
tutorial/t2.c

index 002bf3a8525359651d4bd4131e60492c44bfe37f..7ef2e89bc96dd3bb461fdc28fecf8bff23c07188 100644 (file)
--- 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  <rweather@southern-storm.com.au>
 
        * jit/jit-rules-arm.c (flush_constants): update the instruction
index 75011901576f699837e0ea85f51a85032c45f2de..1ae3d0647ed4eaf31ecc7daecc0eb050489ac123 100644 (file)
@@ -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)
                        {
index 1160e2b4873ea571fb8dd095164b03ae69893b2d..a4d67a2ed0c2103a03b34608dade9884707a21a8 100644 (file)
@@ -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);