https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120120

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2025-05-06 00:00:00         |2025-8-26
             Target|x86_64-*-*                  |x86_64-*-* aarch64
           Keywords|                            |tail-call

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note while this is a regression in GCC 16 for x86_64. aarch64 had the bad
behavior in GCC 15 and before.

Maybe tailr1 should not do a tail call recusion if there is more than one call
to itself with some modified values in the same BB and one of the arguments is
the same across all of those calls and is only one operation from the original
arg.

Like this testcase we have:
```
  size_115 = size_109(D) >> 1;
  src_120 = codec47_block (ctx_116(D), src_104, dst_112(D), p1_117(D),
p2_111(D), w_107(D), coltbl_118(D), size_115);
...
  src_122 = codec47_block (ctx_116(D), src_120, _10, _12, _13, w_107(D),
coltbl_118(D), size_115);
...
  src_127 = codec47_block (ctx_116(D), src_122, dst_123, p1_124, p2_125,
w_107(D), coltbl_118(D), size_115);
...
  src_129 = codec47_block (ctx_116(D), src_127, _18, _19, _20, w_107(D),
coltbl_118(D), size_115);
```

so we can see that size_115 is the same between those call and it was based on
shifting by 1 from the original arg.  Basically what is allowed for a "jump
function" for IPA CP.

If there was only the call we are tailing call to, then we don't need to block
the tail call in this case.

Reply via email to