diff options
author | Jakub Jelinek <jakub@redhat.com> | 2025-04-01 11:43:16 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2025-04-01 11:43:16 +0200 |
commit | 02409a145946ca0d4f502f43fc3cc20de8b3dea1 (patch) | |
tree | 01bd160485fbd66ff953c2dac84e0007a73c6e31 /gcc/rust/backend/rust-compile-expr.cc | |
parent | a6c2248cfd4bc922378f554578ee44e6b4690f5d (diff) | |
download | gcc-02409a145946ca0d4f502f43fc3cc20de8b3dea1.zip gcc-02409a145946ca0d4f502f43fc3cc20de8b3dea1.tar.gz gcc-02409a145946ca0d4f502f43fc3cc20de8b3dea1.tar.bz2 |
tailr: Punt on tail recursions that would break musttail [PR119493]
While working on the previous tailc patch, I've noticed the following
problem.
The testcase below fails, because we decide to tail recursion optimize
the call, but tail recursion (as documented in tree-tailcall.cc) needs to
add some result multiplication and/or addition if any tail recursion uses
accumulator, which is added right before the return.
So, if there are musttail non-recurive calls in the function, successful
tail recursion optimization will mean we'll later error on the musttail
calls. musttail recursive calls are ok, those would be tail recursion
optimized.
So, the following patch punts on all tail recursion optimizations if it
needs accumulators (add and/or mult) if there is at least one non-recursive
musttail call.
2025-04-01 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/119493
* tree-tailcall.cc (tree_optimize_tail_calls_1): Ignore tail recursion
candidates which need accumulators if there is at least one musttail
non-recursive call.
* gcc.dg/pr119493-2.c: New test.
Diffstat (limited to 'gcc/rust/backend/rust-compile-expr.cc')
0 files changed, 0 insertions, 0 deletions