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 tree-optimization/56407] [4.7 Regression] Optimizations (-O2 -O3) make comparison of arrays of ints to fail
Date: Wed, 03 Apr 2013 10:23:00 -0000	[thread overview]
Message-ID: <bug-56407-4-AvKHfS8asd@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-56407-4@http.gcc.gnu.org/bugzilla/>


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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> 2013-04-03 10:22:53 UTC ---
Testcase, also fails at -O2:

/* { dg-do run } */

extern void abort(void);
extern int rand(void);

static void copy(int *r,int *a,int na)
{
  int i;
  for( i = 0 ; i < na ; i++ )
    r[i] = a[i];
}

static void foo(int *a,int na)
{
  int i;
  for( i = 0 ; i < na ; i++ )
    a[i] = rand();
}

static int cmp(int *a,int *b,int n)
{
  int i;
  for( i = 0 ; i < n ; i++ )
    if ( a[i] != b[i] )
      return -1;
  return 0;
}

void __attribute__((noinline,noclone))
test(int sz,int comm)
{
  int j,n;
  int v[64],w[64];
  for( j = 1 ; j <= sz ; j++ )
    {
      n = (2 * j - 1) * (2 * j - 1);
      foo(w,n);
      copy(v,w,n);
      if ( comm )
        if ( cmp(v,w,n) ) abort ();
    }
}

int main()
{
  test(2,1);
  return 0;
}


  parent reply	other threads:[~2013-04-03 10:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-20 11:53 [Bug c/56407] New: " quintin at lix dot polytechnique.fr
2013-02-20 13:11 ` [Bug c/56407] [4.7 Regression] " jakub at gcc dot gnu.org
2013-04-03  9:53 ` [Bug tree-optimization/56407] " rguenth at gcc dot gnu.org
2013-04-03 10:23 ` rguenth at gcc dot gnu.org [this message]
2013-04-03 10:26 ` rguenth at gcc dot gnu.org
2013-04-11  7:59 ` rguenth at gcc dot gnu.org
2014-06-12 13:24 ` rguenth 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=bug-56407-4-AvKHfS8asd@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).