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

            Bug ID: 81427
           Summary: Bad optimization for fibonacci function on PowerPC
           Product: gcc
           Version: 6.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Simon.Richter at hogyros dot de
  Target Milestone: ---

Created attachment 41742
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=41742&action=edit
Generated assembler code

Compiling the code

    #include <stdint.h>

    uint64_t fib(uint64_t n)
    {
        if(n == 0 || n == 1)
            return n;
        return fib(n-1) + fib(n-2);
    }

for PowerPC (be/le, 32/64 in any combination) with -O3 gives a lengthy function
that is clearly suboptimal (each recursion level saves r14-r31 in a 320 bytes
stack frame. The code generated without optimizer looks sane.

Reply via email to