]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
regalloc bugfix
authorAleksey Demakov <ademakov@gmail.com>
Thu, 16 Apr 2009 05:38:54 +0000 (05:38 +0000)
committerAleksey Demakov <ademakov@gmail.com>
Thu, 16 Apr 2009 05:38:54 +0000 (05:38 +0000)
ChangeLog
jit/jit-reg-alloc.c

index 6e1c4cd526ed45f28851807826ec32a221cda554..493615a05db72e553ecde1ae4cdfa95c3a91a992 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-16  Aleksey Demakov  <ademakov@gmail.com>
+
+       * jit/jit-reg-alloc.c (set_regdesc_flags): fix bug reported by
+       jan@wedesoft.de.
+
 2009-04-05  Michele Tartara  <mikyt@users.sourceforge.net>
 
        * jit/jit-type.c (perform_layout): let struct alignment be greater
index d66d84e00a3fca90c97688793f9ca76e82a4e5f8..a16f4d27ae89c7e6e29c9717678ac53f0219aecb 100644 (file)
@@ -620,6 +620,20 @@ set_regdesc_flags(jit_gencode_t gen, _jit_regs_t *regs, int index)
 
        /* See if the value clobbers the register it is assigned to. */
        clobber = clobbers_register(gen, regs, index, desc->reg, desc->other_reg);
+#ifdef JIT_REG_DEBUG
+       if((clobber & CLOBBER_INPUT_VALUE) != 0)
+       {
+               printf("clobber input\n");
+       }
+       if((clobber & CLOBBER_REG) != 0)
+       {
+               printf("clobber reg\n");
+       }
+       if((clobber & CLOBBER_OTHER_REG) != 0)
+       {
+               printf("clobber other reg\n");
+       }
+#endif
 
        /* See if this is an input value and whether it is alive. */
        if(regs->ternary)
@@ -733,38 +747,58 @@ set_regdesc_flags(jit_gencode_t gen, _jit_regs_t *regs, int index)
                        }
                }
 
-               /* See if the input value is destroyed by the instruction. */
-               if(desc->copy)
-               {
-                       clobber_input = 0;
-               }
-               else if(jit_reg_is_used(regs->clobber, desc->reg)
-                       || (desc->other_reg >= 0
-                           && jit_reg_is_used(regs->clobber, desc->other_reg)))
-               {
-                       clobber_input = 1;
-               }
-               else
-               {
-                       clobber_input = ((clobber & CLOBBER_INPUT_VALUE) != 0);
-               }
-
                /* See if the input value needs to be stored before the
                   instruction and if it stays in the register after it. */
                if(desc->value->is_constant)
                {
                        desc->kill = 1;
                }
-               else if(clobber_input)
-               {
-                       desc->store = (is_live_input || is_used_input);
-                       desc->kill = 1;
-               }
                else if(!is_used_input)
                {
                        desc->store = is_live_input;
                        desc->kill = 1;
                }
+               else
+               {
+                       /* See if the input value is destroyed by the instruction. */
+                       clobber_input = 0;
+                       if(!desc->copy)
+                       {
+                               if(jit_reg_is_used(regs->clobber, desc->reg)
+                                  || (desc->other_reg >= 0
+                                      && jit_reg_is_used(regs->clobber, desc->other_reg)))
+                               {
+                                       clobber_input = 1;
+                               }
+                               else if ((clobber & CLOBBER_INPUT_VALUE) != 0)
+                               {
+                                       clobber_input = 1;
+                               }
+                       }
+                       else if(reg >= 0)
+                       {
+                               if(jit_reg_is_used(regs->clobber, reg)
+                                  || (other_reg >= 0
+                                      && jit_reg_is_used(regs->clobber, other_reg)))
+                               {
+                                       clobber_input = 1;
+                               }
+                               else if(!regs->ternary
+                                       && regs->descs[0].value
+                                       && (reg == regs->descs[0].reg
+                                           || reg == regs->descs[0].other_reg
+                                           || other_reg == regs->descs[0].reg))
+                               {
+                                       clobber_input = 1;
+                               }
+                       }
+
+                       if(clobber_input)
+                       {
+                               desc->store = 1;
+                               desc->kill = 1;
+                       }
+               }
 
                /* Store the value if it is going to be thrashed by another one. */
                if(desc->thrash)