Perfectly fine code seems to give segmentation faults on PowerPC with the new -floop-optimize flag. I've only tested this with GCC 3.3.2 from Debian unstable. Here's a small example of code which gives SIGSEGV http://www.rashbox.org/~chlunde/gccloopbug.cc
Looks like some how this insn is being splitted up: (insn 164 117 166 0x0 (parallel [ (set (reg:DF 127) (unsigned_float:DF (reg/v:SI 122))) (use (reg:SI 128)) (use (reg:DF 129)) (clobber (mem:DF (plus:SI (reg/f:SI 30 r30) (reg:SI 141)) [0 S8 A8])) (clobber (reg:DF 130)) ]) -1 (nil) (expr_list:REG_EQUAL (unsigned_float:DF (reg/v:SI 122)) (nil)))
Here is the code: /* * This gives me a SIGSEGV when compiled with -floop-optimize on PPC w/3.3 * chlunde at ifi.uio.no */ #include <math.h> typedef unsigned int uint; int main(int, char**) { const uint size = 181; // 180 and lower seems to work unsigned char data[size][size]; for(uint x = 0; x < size; ++x) { for(uint y = 0; y < size; ++y) { int intensity = (int)(x * 10.0); // This is needed data[y][x] = (intensity >= 0) ? 0 : 1; } } } // vim: ts=2 sw=2 et
The include to math.h is not needed. I can reproduce it on the mainline (20031029).
[ reported to http://bugs.debian.org/218219 as well ]
Patch here: <http://gcc.gnu.org/ml/gcc-patches/2003-12/msg00785.html>.
Dale the patch was okayed, could you apply it?
Subject: Bug 12828 CVSROOT: /cvs/gcc Module name: gcc Changes by: dalej@gcc.gnu.org 2003-12-22 18:23:15 Modified files: gcc : ChangeLog regclass.c loop.c Log message: 2003-12-21 Dale Johannesen <dalej@apple.com> PR optimization/12828 * loop.c: Add find_regs_nested to look inside CLOBBER(MEM). (scan_loop): Call it. * regclass.c (reg_scan_mark_regs): Look inside CLOBBER(MEM). Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.2072&r2=2.2073 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/regclass.c.diff?cvsroot=gcc&r1=1.182&r2=1.183 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/loop.c.diff?cvsroot=gcc&r1=1.482&r2=1.483
Fixed by patch shown in #7.
*** Bug 14947 has been marked as a duplicate of this bug. ***
*** Bug 17072 has been marked as a duplicate of this bug. ***
*** Bug 20327 has been marked as a duplicate of this bug. ***