public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/38691]  New: missed optimization with const pointers
@ 2009-01-02  9:50 tkoenig at gcc dot gnu dot org
  2009-01-02 10:29 ` [Bug tree-optimization/38691] " rguenth at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: tkoenig at gcc dot gnu dot org @ 2009-01-02  9:50 UTC (permalink / raw)
  To: gcc-bugs

This is one possible C equivalent of PR 23169, a Fortran PR.

$ cat foo.c
void bar(const int *, const int *);

int foo(const int *b, const int *c)
{
    int d,e;
    d = *b;
    e = *c;

    bar(b, c);
    return (d- *b) + (e - *c);
}
$ gcc -O3 -fdump-tree-optimized -S foo.c
$ cat foo.c.123t.optimized

;; Function foo (foo)

Analyzing Edge Insertions.
foo (const int * b, const int * c)
{
  int e;
  int d;

<bb 2>:
  d = *b;
  e = *c;
  bar (b, c);
  return ((e - *b) + d) - *c;

}

Without the call to bar, the function is optimized
to "return 0".  This should be possible even with the
call to bar, because all pointers in sight are marked const.


-- 
           Summary: missed optimization with const pointers
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: alias
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tkoenig at gcc dot gnu dot org
OtherBugsDependingO 23169
             nThis:


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


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

* [Bug tree-optimization/38691] missed optimization with const pointers
  2009-01-02  9:50 [Bug tree-optimization/38691] New: missed optimization with const pointers tkoenig at gcc dot gnu dot org
@ 2009-01-02 10:29 ` rguenth at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2009-01-02 10:29 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2009-01-02 10:27 -------
const doesn't have any semantic meaning.  Which means that it is valid for bar
to change the memory pointed to by its arguments - just not through the const
qualified pointers.

There is no way to tell the middle-end about anonymous readonly memory.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

end of thread, other threads:[~2009-01-02 10:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-02  9:50 [Bug tree-optimization/38691] New: missed optimization with const pointers tkoenig at gcc dot gnu dot org
2009-01-02 10:29 ` [Bug tree-optimization/38691] " rguenth 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).