Compiling this test case with -O2 -std=c99:

void f(int *restrict r,
       int a[restrict 16][16],
       int b[restrict 16][16],
       int i,
       int j)
{
  int x;
  *r = 0;
  for (x = 1; x < 16; ++x)
    *r = *r + a[i][x] * b[x][j];
}

does not sink the store to "*r" outside of the loop; we end up writing to "*r"
on every loop iteration.  We do sink the store with "-fargument-noalias" so
that is somehow stronger in this case than using "restrict".  Despite other
hard problems with "restrict", it seems like the special case of "all pointer
arguments use restrict" should be equivalent to "-fargument-noalias is in
effect".


-- 
           Summary: Compiler does not take advantage of restrict
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mmitchel at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: arm-none-linux-gnueabi


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

Reply via email to