This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/81427] New: Bad optimization for fibonacci function on PowerPC
- From: "Simon.Richter at hogyros dot de" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 13 Jul 2017 09:27:28 +0000
- Subject: [Bug tree-optimization/81427] New: Bad optimization for fibonacci function on PowerPC
- Auto-submitted: auto-generated
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.