public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/43827]  New: Intrinsic possibility: does not alias global data
@ 2010-04-21  3:40 darkshikari at gmail dot com
  2010-04-21  9:30 ` [Bug c/43827] " rguenth at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: darkshikari at gmail dot com @ 2010-04-21  3:40 UTC (permalink / raw)
  To: gcc-bugs

Take this code snippet from x264:

h->mc.mc_luma( pix   , 64, m->p_fref, m->i_stride[0], omx, omy-1, bw, bh,
&m->weight[0] );
h->mc.mc_luma( pix+16, 64, m->p_fref, m->i_stride[0], omx, omy+1, bw, bh,
&m->weight[0] );
h->mc.mc_luma( pix+32, 64, m->p_fref, m->i_stride[0], omx-1, omy, bw, bh,
&m->weight[0] );
h->mc.mc_luma( pix+48, 64, m->p_fref, m->i_stride[0], omx+1, omy, bw, bh,
&m->weight[0] );

After each call to mc_luma, gcc reloads h->mc.mc_luma,  m->p_fref, and
m->i_stride[0] even if restrict is used.  It does this because it cannot prove
at compile-time that none of these are pointers to some global data which
mc_luma might modify.  Being that mc_luma is a function pointer, even link-time
optimization may have trouble proving this sort of thing.  Obviously we could
create local variables for all of these values, but when trying to optimize
huge amounts of code, this quickly becomes ugly and messy.

A solution for this problem might be an intrinsic to tell gcc that a particular
pointer never aliases global/static data and thus can be assumed to be
unchanged across function calls--and thus does not need to be reloaded.

Another, similar solution might be an intrinsic that says that a given function
never modifies global state.  This could be applied to a function pointer as
well as a function.  That would instead offload the task to the individual
function instead of the individual pointer.

Alexander Strange suggested that some of this might be possible in 4.6 given
the IPA-PTA optimization framework, so I'm curious whether these ideas are
feasible or not.


-- 
           Summary: Intrinsic possibility: does not alias global data
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: darkshikari at gmail dot com


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


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

end of thread, other threads:[~2015-03-17  6:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-43827-4@http.gcc.gnu.org/bugzilla/>
2015-03-17  6:54 ` [Bug c/43827] Intrinsic possibility: does not alias global data mpolacek at gcc dot gnu.org
2010-04-21  3:40 [Bug c/43827] New: " darkshikari at gmail dot com
2010-04-21  9:30 ` [Bug c/43827] " rguenth at gcc dot gnu dot org
2010-04-21 22:07 ` darkshikari at gmail dot com
2010-04-21 22:09 ` pinskia at gcc dot gnu dot org
2010-04-21 22:25 ` darkshikari at gmail dot com
2010-04-22  6:31 ` darkshikari at gmail dot com

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