https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56139
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords|deferred |
Priority|P3 |P2
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The main reason IPA doesn't get this is that we end up with
int func (int i)
{
long unsigned int _1;
long unsigned int _2;
int * _3;
int _4;
<bb 2> [local count: 1073741824]:
_1 = (long unsigned int) i_5(D);
_2 = _1 * 4;
_3 = &x + _2;
_4 = *_3;
bar (_4);
return 0;
}
thus an IPA_ADDR ref of 'x' and 'x' TREE_ADDRESSABLE. We do not try to
handle address-taken statics in full generality though eventually
modref-like analysis might be able to compute that the address of the
static variable doesn't escape from 'func' and that 'func' doesn't write
to 'x'?
Not re-creating x[i] is a correctness issue, that cannot be recovered.
One could abuse TARGET_MEM_REF to avoid the address-taking though, but
that would be abuse and likely pessimization as TMR isn't handled in
full generality in a lot of passes.