public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/29145]  New: unsafe use of restrict qualifier
@ 2006-09-19 15:55 djg at cray dot com
  2006-09-19 16:43 ` [Bug tree-optimization/29145] " pinskia at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: djg at cray dot com @ 2006-09-19 15:55 UTC (permalink / raw)
  To: gcc-bugs

In the test case below, GCC doesn't observe a non-restrict-qualified
pointer being "based on" a restrict-qualified pointer. On i686-pc-linux-gnu, 
this program aborts when compiled with
-O2 -msse -ftree-vectorize
because the loop in function with_restrict is vectorized based on an unsafe
alias assumption.

void abort(void);
void exit(int);

void with_restrict(int * __restrict p)
{
  int i;
  int *q = p - 2;

  for (i = 0; i < 1000; ++i) {
    p[i] = q[i];
  }
}

void without_restrict(int * p)
{
  int i;
  int *q = p - 2;

  for (i = 0; i < 1000; ++i) {
    p[i] = q[i];
  }
}

int main(void)
{
  int i;
  int a[1002];
  int b[1002];

  for (i = 0; i < 1002; ++i) {
    a[i] = b[i] = i;
  }

  with_restrict(a + 2);
  without_restrict(b + 2);

  for (i = 0; i < 1002; ++i) {
    if (a[i] != b[i])
      abort();
  }
  exit(0);
}


-- 
           Summary: unsafe use of restrict qualifier
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: djg at cray dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-07-01  8:32 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-19 15:55 [Bug tree-optimization/29145] New: unsafe use of restrict qualifier djg at cray dot com
2006-09-19 16:43 ` [Bug tree-optimization/29145] " pinskia at gcc dot gnu dot org
2006-09-20 23:49 ` djg at cray dot com
2006-11-02 16:07 ` ian at airs dot com
2006-11-02 16:10 ` rguenth at gcc dot gnu dot org
2006-11-04  4:15 ` dberlin at gcc dot gnu dot org
2006-11-05 15:48 ` dorit at il dot ibm dot com
2006-11-05 16:50 ` djg at cray dot com
2007-01-07 20:22 ` dorit at il dot ibm dot com
2007-01-09  9:35 ` patchapp at dberlin dot org
2007-01-26 21:09 ` djg at cray dot com
2007-02-06  8:18 ` dorit at il dot ibm dot com
2007-02-12 13:15 ` dorit at gcc dot gnu dot org
2007-07-01  8:32 ` dorit at gcc dot gnu dot org

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