[Bug middle-end/65391] New: unnecessary load of conditionally updated pointer in loop
acsawdey at linux dot vnet.ibm.com
gcc-bugzilla@gcc.gnu.org
Wed Mar 11 16:12:00 GMT 2015
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).
More information about the Gcc-bugs
mailing list