[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 01:33:49 PDT 2020


efriedma added a comment.

What happens if there are multiple tail calls in a function using different accumulators?  Something like the following:

  int f(int a) {
    if (!a) return 0;
    if (a & 1) { return f(a-1)+1; }
    return f(a-1)*2;
  }



================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:797
+          AccRecInstrNew->insertBefore(SI);
+          SI->setFalseValue(AccRecInstrNew);
+        }
----------------
I don't see any tests involving an accumulator and a select?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D80844/new/

https://reviews.llvm.org/D80844





More information about the llvm-commits mailing list