------- Comment #7 from vmakarov at redhat dot com  2009-04-24 15:53 -------
In gcc4.4 we have before reg-stack.c

(insn 96 82 97 4 /home/vmakarov/build/bb.ii:8 (parallel [
            (set (mem/c:SI (plus:SI (reg/f:SI 7 sp)
                        (const_int 28 [0x1c])) [0 S4 A32])
                (fix:SI (reg:DF 9 st(1))))
            (clobber (reg:XF 9 st(1)))
        ]) 119 {fix_truncsi_i387_fisttp} (expr_list:REG_DEAD (reg:DF 9 st(1))
        (nil)))

in subst_stack_regs first it is changed to 

(insn:TI 96 82 97 4 /home/vmakarov/build/bb.ii:8 (parallel [
            (set (mem/c:SI (plus:SI (reg/f:SI 7 sp)
                        (const_int 28 [0x1c])) [0 S4 A32])
                (fix:SI (reg:DF 8 st)))
            (clobber (reg:XF 9 st(1)))
        ]) 119 {fix_truncsi_i387_fisttp} (expr_list:REG_DEAD (reg:DF 8 st)
        (nil)))

Then it is trying to change clobber and fail because there is no note
about dead or unused reg 9, it fails in subst_stack_regs_pat on the
assert:

                if (note)
                  emit_pop_insn (insn, regstack, *dest, EMIT_BEFORE);
                else
                  {
                    note = find_reg_note (insn, REG_UNUSED, *dest);
                    gcc_assert (note);
                  }


The gcc4.3 has analogous insn before reg-stack.c

(insn 106 92 107 4 bb.ii:8 (parallel [
            (set (mem/c:SI (plus:SI (reg/f:SI 7 sp)
                        (const_int 28 [0x1c])) [0 S4 A8])
                (fix:SI (reg:DF 11 st(3))))
            (clobber (reg:XF 11 st(3)))
        ]) 159 {fix_truncsi_i387_fisttp} (expr_list:REG_DEAD (reg:DF 11 st(3))
        (expr_list:REG_UNUSED (reg:XF 11 st(3))
            (nil))))

The difference is in presense of REG_UNUSED (reg:XF 11 st(3)) which
does not permit the gcc_assert aborts gcc4.3.  The note is present
because LR_OUT at BB 4 does not contain 11 st(3).  Quite opposite, 9
st(1) is in LR_OUT at BB 4 in gcc4.4.  Therefore REG_UNUSED note is
not generated for gcc4.4.

So why there is such difference in LR_OUT for 4.3 vs 4.4?  Gcc4.3 is
lucky to use 11 st (3) only in BB3 (where insn 116 is placed).  Gcc4.4
uses 9 st(1) in insn 96 and reuses it in many other BBs.  Because of
partially set register for variable R, we got that LR_OUT is set up in
BB 3.  If somebody is interesting here is the CFG with LR_OUT & LR_IN
and usage of 9 st (1):

0
|
v
2-->
|  |
v  |
3->|  lr_out:9                 set 9;use 9;clobber 9
|  |
v  |
4  |  lr_out:9                 call
|  |
v  |
5<-   lr_in:9 lr_out:9
|\
| \
6->|  lr_out:9                 set 9
|  |
|  |
7  |  lr_in:9 lr_out:9         use 9 .. set 9
|  |
|  |
8<-   lr_in:9 lr_out:9
|\
| \
9  |  lr_in:9                  use 9
|  |
|  |
10<-

So the code 

                if (note)
                  emit_pop_insn (insn, regstack, *dest, EMIT_BEFORE);
                else
                  {
                    note = find_reg_note (insn, REG_UNUSED, *dest);
                    gcc_assert (note);
                  }

does not take situation of reusage of hard register for partially set
variable.

IMHO, the code should be

Index: reg-stack.c
===================================================================
--- reg-stack.c (revision 146648)
+++ reg-stack.c (working copy)
@@ -1381,11 +1381,9 @@ subst_stack_regs_pat (rtx insn, stack re
                if (note)
                  emit_pop_insn (insn, regstack, *dest, EMIT_BEFORE);
                else
-                 {
-                   note = find_reg_note (insn, REG_UNUSED, *dest);
-                   gcc_assert (note);
-                 }
-               remove_note (insn, note);
+                 note = find_reg_note (insn, REG_UNUSED, *dest);
+               if (note)
+                 remove_note (insn, note);
                replace_reg (dest, FIRST_STACK_REG + 1);
              }
            else

I'll send the patch soon.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39856

Reply via email to