https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128074
Josef Melcr <jmelcr at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at redhat dot com,
| |jamborm at gcc dot gnu.org,
| |jmelcr at gcc dot gnu.org
Summary|wrong code at -O3 for a |[16/17 Regression] wrong
|self-recursive call that |code at -O3 for a
|passes a struct to a const |self-recursive call that
|struct parameter |passes a struct to a const
| |struct parameter
--- Comment #1 from Josef Melcr <jmelcr at gcc dot gnu.org> ---
r16-180-gb0120fa9838f8f
`f` is tail call optimized:
int f (const struct S a, int n)
{
const int a$x;
struct S t;
int _2;
int _3;
<bb 5> [local count: 118111600]:
<bb 2> [local count: 1073741824]:
# n_4 = PHI <n_6(D)(5), _3(3)>
a$x_8 = a.x;
if (n_4 != 0)
goto <bb 3>; [89.00%]
else
goto <bb 4>; [11.00%]
<bb 3> [local count: 955630224]:
_2 = a$x_8 + 1;
t.x = _2;
_3 = n_4 + -1;
a = t; <-- assignment to const?
goto <bb 2>; [100.00%]
<bb 4> [local count: 118111600]:
return a$x_8;
}
ipa-cp later propagates 0 into a.x. Since a$x_8 is never assigned again, hence
the body gets folded to return 0