public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vmakarov at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/39856] [4.4/4.5 Regression] ICE in subst_stack_regs_pat, at reg-stack.c:1386
Date: Fri, 24 Apr 2009 15:54:00 -0000	[thread overview]
Message-ID: <20090424155346.5522.qmail@sourceware.org> (raw)
In-Reply-To: <bug-39856-10053@http.gcc.gnu.org/bugzilla/>



------- 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


  parent reply	other threads:[~2009-04-24 15:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-22 21:08 [Bug target/39856] New: [4.4 " rguenth at gcc dot gnu dot org
2009-04-22 21:08 ` [Bug target/39856] " rguenth at gcc dot gnu dot org
2009-04-22 22:05 ` jakub at gcc dot gnu dot org
2009-04-23  8:46 ` jakub at gcc dot gnu dot org
2009-04-23  8:50 ` jakub at gcc dot gnu dot org
2009-04-23  9:14 ` jakub at gcc dot gnu dot org
2009-04-23 17:27 ` vmakarov at redhat dot com
2009-04-23 18:15 ` [Bug target/39856] [4.4/4.5 " jakub at gcc dot gnu dot org
2009-04-24 15:54 ` vmakarov at redhat dot com [this message]
2009-05-05 15:56 ` mmitchel at gcc dot gnu dot org
2009-05-21 14:07 ` jakub at gcc dot gnu dot org
2009-05-22 19:00 ` vmakarov at gcc dot gnu dot org
2009-05-22 19:01 ` vmakarov at gcc dot gnu dot org
2009-05-28 22:39 ` jakub at gcc dot gnu dot org
     [not found] <bug-39856-4@http.gcc.gnu.org/bugzilla/>
2021-08-09  3:51 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090424155346.5522.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).