[Bug tree-optimization/34114] Missed optimization: cannot determine loop termination
lloyd at randombit dot net
gcc-bugzilla@gcc.gnu.org
Fri Nov 16 01:49:00 GMT 2007
------- Comment #3 from lloyd at randombit dot net 2007-11-16 01:49 -------
Here's another example, which I think may represent a different case (and which
I found much more surprising than the first):
$ cat no_loop_opt2.c
void g(unsigned int n)
{
unsigned int k;
for(k = 0; k <= n; ++k)
;
}
(motoko ~)$ g++-4.1.2 -O2 -Wunsafe-loop-optimizations -c no_loop_opt2.c
no_loop_opt2.c: In function 'void g(unsigned int)':
no_loop_opt2.c:5: warning: cannot optimize possibly infinite loops
no_loop_opt2.c:5: warning: cannot optimize possibly infinite loops
no_loop_opt2.c:5: warning: cannot optimize possibly infinite loops
no_loop_opt2.c:5: warning: cannot optimize possibly infinite loops
(same output with 4.2.0)
However if <= is changed to <, no problem.
Version info:
$ g++-4.1.2 -v
Using built-in specs.
Target: x86_64-pc-linux-gnu
Configured with: /var/tmp/portage/sys-devel/gcc-4.1.2/work/gcc-4.1.2/configure
--prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.1.2
--includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include
--datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.2
--mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.2/man
--infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.1.2/info
--with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.1.2/include/g++-v4
--host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec
--enable-nls --without-included-gettext --with-system-zlib --disable-checking
--disable-werror --enable-secureplt --disable-libunwind-exceptions
--enable-multilib --enable-libmudflap --disable-libssp --disable-libgcj
--enable-languages=c,c++,objc,obj-c++,fortran --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 4.1.2 (Gentoo 4.1.2)
$ g++-4.2.0 -v
Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.2.0/configure --enable-languages=c,c++,objc,obj-c++
--program-suffix=-4.2.0
Thread model: posix
gcc version 4.2.0
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34114
More information about the Gcc-bugs
mailing list