[PATCH] D80844: [TRE] Allow accumulator elimination when base case returns non-constant
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 1 19:30:14 PDT 2020
efriedma added a comment.
> Currently on trunk, and after this patch, we only eliminate the first accumulating call we find and ignore any potential others.
Well, on trunk, we fail out of tail recursion elimination completely, I think. But yes, makes sense.
I'd like to see a testcase for this.
> In cases like the one you posted with different accumulator operations (eg. mul add), it is a lot more tricky (and I'm not sure possible) because of the operations happen in reverse order.
In general, with multiple arbitrary accumulator operations, it's impossible, yes: you can't reassociate the operations.
gcc does actually manage to do tail call elimination on my testcase. Roughly, you can distribute the multiplication over the addition. It doesn't seem very important, though.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D80844/new/
https://reviews.llvm.org/D80844
More information about the llvm-commits
mailing list