public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/58831] [4.8/4.9 Regression] wrong code at -O2 and -O3 on x86_64-linux-gnu in 64-bit mode
Date: Wed, 23 Oct 2013 11:19:00 -0000	[thread overview]
Message-ID: <bug-58831-4-ya1pfwqajk@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-58831-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |rtl-optimization

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's instruction scheduling which in fn1 changes

.L8:
        movq    $d, (%rsi)
        movq    $d, b(%rip)
        cmpq    $0, r(%rip)
        je      .L15  // assert-fail

to


.L8:
        cmpq    $0, r(%rip)
        movq    $d, (%rsi)
        movq    $d, b(%rip)
        je      .L15

but %rsi points to r.  Before sched2 we have

(note 22 21 23 4 [bb 4] NOTE_INSN_BASIC_BLOCK)
(insn 23 22 24 4 (set (mem/f:DI (reg/v/f:DI 4 si [orig:90 p2 ] [90]) [3
*p2_9(D)+0 S8 A64])
        (symbol_ref:DI ("d")  <var_decl 0x7f8900812720 d>)) t.c:12 85
{*movdi_internal}
     (expr_list:REG_DEAD (reg/v/f:DI 4 si [orig:90 p2 ] [90])
        (nil)))
(insn 24 23 25 4 (set (mem/f/c:DI (symbol_ref:DI ("b")  <var_decl
0x7f89008125f0 b>) [3 b+0 S8 A64])
        (symbol_ref:DI ("d")  <var_decl 0x7f8900812720 d>)) t.c:12 85
{*movdi_internal}
     (nil))
(insn 25 24 26 4 (set (reg:CCZ 17 flags)
        (compare:CCZ (mem/f/c:DI (symbol_ref:DI ("r")  <var_decl 0x7f8900812a18
r>) [3 r+0 S8 A64])
            (const_int 0 [0]))) t.c:14 4 {*cmpdi_ccno_1}
     (nil))
(jump_insn 26 25 35 4 (set (pc)

seems to be dependent on code-changes in random places :/

Somewhat shorter testcase:

#include<assert.h>

int a, *b, c, d, f, **i, p, q, *r;
short o, j;

static int __attribute__((noinline, noclone))
fn1 (int *p1, int **p2)
{
  int **e = &b;
  for (; p; p++)
    *p1 = 1;
  *e = *p2 = &d;

  assert (r);

  return c;
}

static int ** __attribute__((noinline, noclone))
fn2 ()
{
  for (f = 0; f != 42; f++)
    {
      int *g[3] = {0, 0, 0};
      for (o = 0; o; o--)
        for (; a > 1;)
          {
            int **h[1] = { &g[2] };
          }
    }
  return &r;
}

int
main ()
{
  i = fn2 ();
  fn1 (b, i);
  return 0;
}


  parent reply	other threads:[~2013-10-23 11:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-21 23:05 [Bug tree-optimization/58831] New: " su at cs dot ucdavis.edu
2013-10-22 21:14 ` [Bug tree-optimization/58831] " mikpelinux at gmail dot com
2013-10-23  8:19 ` [Bug tree-optimization/58831] [4.8/4.9 Regression] " rguenth at gcc dot gnu.org
2013-10-23 11:19 ` rguenth at gcc dot gnu.org [this message]
2013-10-23 11:39 ` [Bug rtl-optimization/58831] " rguenth at gcc dot gnu.org
2013-10-23 11:42 ` rguenth at gcc dot gnu.org
2013-10-25  9:21 ` ebotcazou at gcc dot gnu.org
2013-10-25  9:24 ` ebotcazou at gcc dot gnu.org
2013-10-25  9:31 ` ebotcazou at gcc dot gnu.org
2013-10-25 10:09 ` rguenth at gcc dot gnu.org
2013-10-25 10:10 ` rguenth at gcc dot gnu.org
2013-10-25 10:12 ` [Bug rtl-optimization/58831] [4.7/4.8/4.9 " rguenth at gcc dot gnu.org
2013-10-25 10:14 ` rguenth at gcc dot gnu.org
2013-10-25 11:17 ` ebotcazou at gcc dot gnu.org
2013-10-25 11:18 ` ebotcazou at gcc dot gnu.org
2013-10-28  7:10 ` su at cs dot ucdavis.edu

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=bug-58831-4-ya1pfwqajk@http.gcc.gnu.org/bugzilla/ \
    --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).