[llvm-bugs] [Bug 51461] New: Missed accumulator recursion elimination

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 12 13:49:13 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=51461

            Bug ID: 51461
           Summary: Missed accumulator recursion elimination
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: llvm at rifkin.dev
                CC: llvm-bugs at lists.llvm.org

Of the following simple recursive functions, LLVM is able to eliminate
recursion for foo but not bar:

int foo(int n) {
    if(n <= 0) return 1;
    return 2 + foo(n - 1);
}
int bar(int n) {
    if(n <= 0) return 1;
    return 2 * bar(n - 1);
}

GCC optimizes both. https://godbolt.org/z/rozMcn6o4.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210812/50015d56/attachment.html>


More information about the llvm-bugs mailing list