[Bug tree-optimization/114206] recursive function call vs local variable addresses
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Mon Mar 4 09:54:56 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114206
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever confirmed|0 |1
Last reconfirmed| |2024-03-04
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
So we simplify this and RTL expand from
int f (int t, const int * a)
{
const int b[4];
_Bool _1;
int _8;
<bb 2> [local count: 1073741824]:
if (t_3(D) == 0)
goto <bb 3>; [49.25%]
else
goto <bb 4>; [50.75%]
<bb 3> [local count: 528857912]:
<bb 4> [local count: 1073741824]:
# a_11 = PHI <a_5(D)(2), &b(3)>
_1 = &b == a_11;
_8 = (int) _1;
b ={v} {CLOBBER(eos)};
return _8;
We apply tail-recursion optimization here which coalescs both slots which
are used just by their address. IIRC tail-recursion analysis uses alias
analysis to be able to handle some cases where TREE_ADDRESSABLE vars are
passed.
We miss considering variables live that are passed by reference (but otherwise
are "unused").
As you needed to cut off quite some optimizations to early simplify the
b == a compare this is a bit academic or needs much more obfuscation of the
compare to actually matter.
But yes, it's a bug.
More information about the Gcc-bugs
mailing list