https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98552
Tobias Schlüter <tobi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |tobi at gcc dot gnu.org
--- Comment #1 from Tobias Schlüter <tobi at gcc dot gnu.org> ---
There's a typo in the example, /= instead of !=. Fixed example below:
I sprinkled const's all over foo's prototype and 'i' still gets reloaded so it
stands to reason that the compiler doesn't see the optimization opportunity.
======================
void foo (int *);
void bar (int n)
{
int i;
for (i=0; i<n; i++)
foo(&i);
}
void baz(int n)
{
int i, j;
for (i=0; i<n; i++)
{
j = i;
foo (&i);
if (j != i)
__builtin_unreachable();
}
}
======================