public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/65391] New: unnecessary load of conditionally updated pointer in loop
@ 2015-03-11 16:12 acsawdey at linux dot vnet.ibm.com
  2015-03-11 16:49 ` [Bug middle-end/65391] " dje at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: acsawdey at linux dot vnet.ibm.com @ 2015-03-11 16:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65391

            Bug ID: 65391
           Summary: unnecessary load of conditionally updated pointer in
                    loop
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: acsawdey at linux dot vnet.ibm.com
                CC: dje at gcc dot gnu.org, pthaugen at us dot ibm.com

When compiling for powerpc64 or powerpc64le with -O3, a load and store of
*o_ptr is done inside the loop. 

If you remove the if statement and make the update unconditional, then the load
goes away and the store is deferred until after the loop.

If you remove the __restrict__ keywords, then the store remains in the loop in
either case as expected. However the load is still done in the loop if the
update is conditional.

void compute_object_gain(long * __restrict__ p_ptr, long * __restrict__ o_ptr,
long g_order)
{
    long a_binding;
    *o_ptr = 0;
    while(*p_ptr!=0) {
       a_binding = *p_ptr;
       if(a_binding <= g_order)
          *o_ptr += a_binding;
        p_ptr++;
    }
}

This behavior is consistent on 4.1, 4.5, 4.6, 4.7, 4.8, and 5.0 (trunk 220806).


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

end of thread, other threads:[~2015-03-12 11:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-11 16:12 [Bug middle-end/65391] New: unnecessary load of conditionally updated pointer in loop acsawdey at linux dot vnet.ibm.com
2015-03-11 16:49 ` [Bug middle-end/65391] " dje at gcc dot gnu.org
2015-03-11 17:13 ` acsawdey at linux dot vnet.ibm.com
2015-03-11 19:19 ` acsawdey at linux dot vnet.ibm.com
2015-03-12 11:11 ` [Bug tree-optimization/65391] missed store motion for " rguenth at gcc dot gnu.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).