http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59193
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |RESOLVED
Resolution|--- |INVALID
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Take:
int f(int a)
{
a++;
return a;
}
int g(int a)
{
++a;
return a;
}
------------------- CUT -------------------
The gimplifier produces the exact same IR for both cases:
f (int a)
{
int D.1790;
a = a + 1;
D.1790 = a;
return D.1790;
}
g (int a)
{
int D.1792;
a = a + 1;
D.1792 = a;
return D.1792;
}
------------------- CUT -------------------
So the compiler is already smart enough to remove the "temporary storage" even
at -O0.
With:
int f(int a)
{
int b = a++;
return a;
}
It does not remove it but that is because the result of a++ is not unused.
So it is the gimplifier knows if the result is unused and will not use them
otherwise. This is the same issue as memcpy and its return value.