This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/33027] New: missed optimisation could pull branch out of loop
- From: "tristan at wibberley dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Aug 2007 19:03:43 -0000
- Subject: [Bug other/33027] New: missed optimisation could pull branch out of loop
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following code could be optimised significantly better (to help C++ with
inlined generic-style stuff).
# 1 "doopt.cc"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "doopt.cc"
unsigned int fn(unsigned int n, unsigned int dmax) throw()
{
for (unsigned int d = 0; d < dmax; ++d) {
n += d?d:1;
}
return n;
}
There follows the output of g++ -v -save-temps my-options source-file:
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --disable-bootstrap
Thread model: posix
gcc version 4.3.0 20070802 (experimental)
/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.3.0/cc1plus -E -quiet -v
-D_GNU_SOURCE -DNEW doopt.cc -mtune=generic -O3 -fpch-preprocess -o doopt.ii
ignoring nonexistent directory
"/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../include/c++/4.3.0
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../include/c++/4.3.0/x86_64-unknown-linux-gnu
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/../../../../include/c++/4.3.0/backward
/usr/local/include
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/include
/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.3.0/include-fixed
/usr/include
End of search list.
/usr/local/libexec/gcc/x86_64-unknown-linux-gnu/4.3.0/cc1plus -fpreprocessed
doopt.ii -quiet -dumpbase doopt.cc -mtune=generic -auxbase doopt -O3 -version
-o doopt.s
GNU C++ version 4.3.0 20070802 (experimental) (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.1.2 (Ubuntu 4.1.2-0ubuntu4), GMP version
4.2.1, MPFR version 2.2.1.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 85805da771cde7753774ab06e3a9f9ac
--
Summary: missed optimisation could pull branch out of loop
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: other
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tristan at wibberley dot org
GCC build triplet: x86_64-unknown-linux-gnu
GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33027