This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/22633] New: recursivity -O3 pessimization
- From: "TazForEver at dlfp dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Jul 2005 19:27:59 -0000
- Subject: [Bug c/22633] New: recursivity -O3 pessimization
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Using built-in specs.
Target: powerpc-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib --enable-nls
--without-included-gettext --enable-threads=posix --program-suffix=-4.0
--enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.0-1.4.2.0/jre --enable-mpfr
--disable-multilib --disable-werror --enable-checking=release powerpc-linux-gnu
Thread model: posix
gcc version 4.0.1 (Debian 4.0.1-2)
unsigned factorial(unsigned i)
{
if(i <= 1)
return 1;
else
return i * factorial(i - 1);
}
gcc < 4.0 was never able to optimize this kind of function the right way.
gcc-4.0 is :)
At level -O1, -O2 and -Os, gcc optimizes the recursive call away turning the
function into a simple loop. Impressive. Great :)
But at level -O3, gcc tries to optimize in a very different way : it unrolls 10
times factorial() body, and then makes a recursive call. Bad.
--
Summary: recursivity -O3 pessimization
Product: gcc
Version: 4.0.1
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: TazForEver at dlfp dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: powerpc-linux-gnu
GCC host triplet: powerpc-linux-gnu
GCC target triplet: powerpc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22633