Bug 33272 - Compiler does not take advantage of restrict
Summary: Compiler does not take advantage of restrict
Status: RESOLVED DUPLICATE of bug 14187
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: alias, missed-optimization
Depends on: 14187 16913 29237
Blocks:
  Show dependency treegraph
 
Reported: 2007-08-31 20:13 UTC by Mark Mitchell
Modified: 2008-10-01 14:38 UTC (History)
11 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: arm-none-linux-gnueabi
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-09-01 11:15:21


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Mitchell 2007-08-31 20:13:52 UTC
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".
Comment 1 Richard Biener 2007-09-01 11:15:21 UTC
Nearly a dup.  Search for "restrict" and missed-optimization, alias for more
of them.
Comment 2 Andrew Pinski 2007-09-01 20:12:09 UTC
Well for the RTL level, with this code, one problem is that iv-opts messes up:
  ivtmp.34 = (long unsigned int) &(*(b + 64))[j];

There is a bug for the iv-opts issue too (though I have not had time to look into fixing it the correct way, iv-opts needs a real rewrite).

And also PRE does not remap the pretmp for restrict (this already filed).
Comment 3 Joseph S. Myers 2007-09-02 00:11:33 UTC
Subject: Bug 33272

Author: jsm28
Date: Sun Sep  2 00:11:20 2007
New Revision: 128018

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128018
Log:
	PR middle-end/33272
	* c-decl.c (grokdeclarator): Apply qualifiers to type of parameter
	decayed from array.

testsuite:
	* gcc.dg/c99-arraydecl-3.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/c99-arraydecl-3.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-decl.c
    trunk/gcc/testsuite/ChangeLog

Comment 4 Andrew Pinski 2007-11-05 00:08:21 UTC
Subject: Bug 33272

Author: pinskia
Date: Mon Nov  5 00:08:04 2007
New Revision: 129888

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129888
Log:
Index: ChangeLog
===================================================================
--- ChangeLog   (revision 129887)
+++ ChangeLog   (working copy)
@@ -6447,6 +6447,7 @@
 
 2007-09-02  Joseph Myers  <joseph@codesourcery.com>
 
+       PR c/29237
        PR middle-end/33272
        * c-decl.c (grokdeclarator): Apply qualifiers to type of parameter
        decayed from array.
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog (revision 129887)
+++ testsuite/ChangeLog (working copy)
@@ -3041,6 +3041,7 @@
 
 2007-09-02  Joseph Myers  <joseph@codesourcery.com>
 
+       PR C/29237
        PR middle-end/33272
        * gcc.dg/c99-arraydecl-3.c: New test.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog

Comment 5 Richard Biener 2008-10-01 14:38:03 UTC
The implementation detail of restrict makes the alias-oracle not work properly.
Dup of PR14187 - restrict should be a PTA thing.

*** This bug has been marked as a duplicate of 14187 ***