public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
To: nobody@gcc.gnu.org
Cc: gcc-prs@gcc.gnu.org,
Subject: Re: c/8467: Bug in sibling call optimization
Date: Tue, 05 Nov 2002 15:26:00 -0000	[thread overview]
Message-ID: <20021105232601.9004.qmail@sources.redhat.com> (raw)

The following reply was made to PR c/8467; it has been noted by GNATS.

From: Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: c/8467: Bug in sibling call optimization
Date: Wed, 6 Nov 2002 00:20:46 +0100

 On Tuesday 05 November 2002 21:25, Franz.Sirl-kernel@lauterbach.com wrote:
 > >Number:         8467
 > >Category:       c
 > >Synopsis:       Bug in sibling call optimization
 > >Confidential:   no
 > >Severity:       serious
 > >Priority:       medium
 > >Responsible:    unassigned
 > >State:          open
 > >Class:          sw-bug
 > >Submitter-Id:   net
 > >Arrival-Date:   Tue Nov 05 12:26:00 PST 2002
 > >Closed-Date:
 > >Last-Modified:
 > >Originator:     Franz.Sirl-kernel@lauterbach.com
 > >Release:        gcc-3.2.1pre, gcc-3.3exp
 > >Organization:
 > >Environment:
 >
 > powerpc-linux-gnu
 >
 > >Description:
 >
 > The appended testcase aborts if compiled with -O2, adding
 > -fno-optimize-sibling-calls makes it pass.
 >
 > This is a regression from gcc-2.95.4.
 >
 > >How-To-Repeat:
 >
 > extern void abort (void);
 > extern void exit (int);
 >
 > int aim_callhandler(int sess, int conn, unsigned short family, unsigned
 > short type) {
 >   static int i = 0;
 >
 >   if (!conn)
 >     return 0;
 >
 >   if (type == 0xffff)
 >     {
 >       return 0;
 >     }
 >
 >   if (i >= 1)
 >     abort ();
 >
 >   i++;
 >   return aim_callhandler(sess, conn, family, 0xffff);
 > }
 >
 > int main (void)
 > {
 >   aim_callhandler (0, 1, 0, 0);
 >   exit (0);
 > }
 
 The 4th arg is incorrectly sign-extended during tail recursion. the .rtl dump 
 with debug_call_placeholder_verbose set to 1 in the debugger:
 
 (call_insn 94 68 96 (call_placeholder 84 0 69 79 (cond [
   (const_string "normal") (sequence [
     (insn 84 0 86 (set (reg:SI 3 r3)
                 (reg/v:SI 116)) -1 (nil)
             (nil))
     (insn 86 84 88 (set (reg:SI 4 r4)
                 (reg/v:SI 117)) -1 (nil)
             (nil))
     (insn 88 86 90 (set (reg:SI 5 r5)
                 (reg/v:SI 118)) -1 (nil)
             (nil))
     (insn 90 88 91 (set (reg:SI 6 r6)
                 (const_int 65535 [0xffff])) -1 (nil)
             (nil))
     (call_insn 91 90 93 (parallel[
                     (set (reg:SI 3 r3)
                         (call (mem:SI (symbol_ref:SI ("aim_callhandler")) [0 
 S4 A8])
                             (const_int 0 [0x0])))
                     (use (const_int 0 [0x0]))
                     (clobber (scratch:SI))
                 ] ) -1 (nil)
             (nil)
             (expr_list (use (reg:SI 6 r6))
                 (expr_list (use (reg:SI 5 r5))
                     (expr_list (use (reg:SI 4 r4))
                         (expr_list (use (reg:SI 3 r3))
                             (nil))))))
     (insn 93 91 0 (set (reg:SI 137)
                 (reg:SI 3 r3)) -1 (nil)
             (nil))
     ])
   (const_string "tail_recursion") (sequence [
     (note 69 0 70 NOTE_INSN_DELETED)
     (note 70 69 72 NOTE_INSN_DELETED)
     (insn 72 70 74 (set (reg/v:SI 116)
                 (reg/v:SI 116)) -1 (nil)
             (nil))
     (insn 74 72 76 (set (reg/v:SI 117)
                 (reg/v:SI 117)) -1 (nil)
             (nil))
     (insn 76 74 78 (set (reg/v:SI 118)
                 (reg/v:SI 118)) -1 (nil)
             (nil))
     (insn 78 76 80 (set (reg/v:SI 119)
                 (const_int -1 [0xffffffffffffffff])) -1 (nil)
             (nil))
     (jump_insn 80 78 81 (set (pc)
                 (label_ref 79)) -1 (nil)
             (nil))
     (barrier 81 80 82)
     (barrier 82 81 0)
     ])
   ])) -1 (nil)
     (nil)
     (nil))
 
 Note the difference between insn 90 in the "normal" sequence and insn 78 in 
 the "tail_recursion" sequence! The 0xffff CONST_INT got signed extended, so 
 the compiler took the "short" type of the 4th arg into account, but ignored 
 the "unsigned" one.
 
 Franz.
 


             reply	other threads:[~2002-11-05 23:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-05 15:26 Franz Sirl [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-11-19 12:19 sirl
2002-11-19 12:16 Franz Sirl
2002-11-10 18:36 Mark Mitchell
2002-11-09  2:26 Franz Sirl
2002-11-07 13:16 Franz Sirl
2002-11-05 12:26 Franz.Sirl-kernel

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=20021105232601.9004.qmail@sources.redhat.com \
    --to=franz.sirl-kernel@lauterbach.com \
    --cc=gcc-prs@gcc.gnu.org \
    --cc=nobody@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).