https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106008
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
Keywords|missed-optimization, |
|needs-reduction |
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot
gnu.org
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #3)
> # VUSE <.MEM_699>
> _109 = MEM[(struct loadcmd *)_106 + -56B].mapend;
>
> my only suspicion is that we somehow isolate (and not optimize as
> unreachable)
> the nloadcmds < 1 case in the preceeding case.
Nope the statement we are diagnosing is guarded by nloadcmds > 1.
A reduced testcase looks like the following, needs -Os -fno-ivopts to
reproduce the diagnostics. It is somewhat of a fundamental limit of
the analysis since when walking the virtual use-def chain we look for
aliases but q[-1] doesn't alias q[0] but when walking the backedge
we simply arrive at the very same stmt again and interpret it as if
it were within the same context. That might also be a problem for
passes using walk_aliased_vdefs for other purposes than diagnostics.
I think that when walking a backedge walk_aliased_vdefs would need to
be more careful with interpreting the defs it runs into.
int foo (int n)
{
int *p = __builtin_malloc (n);
int nloadcmds = 0;
int found = 0;
do
{
int *q = &p[nloadcmds++];
*q = n;
if (nloadcmds > 1
&& q[-1] != 7)
found = 1;
}
while (nloadcmds < n);
return found;
}