From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3901 invoked by alias); 14 Oct 2005 11:03:06 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 3893 invoked by uid 48); 14 Oct 2005 11:03:02 -0000 Date: Fri, 14 Oct 2005 11:03:00 -0000 Subject: [Bug c/24361] New: Optimizations -fcse-follow-jumps -fforce-mem break code X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "tromp at cwi dot nl" X-SW-Source: 2005-10/txt/msg01827.txt.bz2 List-Id: -bash-3.00$ gcc -v Using built-in specs. Target: i386-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux Thread model: posix gcc version 4.0.1 20050727 (Red Hat 4.0.1-5) The program below produces incorrect results with -O2 and higher, which I've deduced is due to the combined options -fcse-follow-jumps -fforce-mem #include #include typedef unsigned long Word_t; typedef struct { unsigned char type; unsigned char color; unsigned char left; unsigned char right; } cell; //possible cell types #define WIDTH 3 typedef cell bstate[WIDTH]; // borderstate void wordtostate(Word_t s, int bump, bstate state) { char stack[WIDTH]; int sp,i,type,leftcolor=0; cell *sti; for (sti = &state[i = sp = 0]; i < WIDTH; sti++, i++) { sti->type = type = (s >> (3*i)) & 7; sti->left = sti->right = i; sti->color = leftcolor ^ 1; // assume opposite color if (type & 2) { sti->right = state[sti->left = stack[--sp]].right; state[sti->left].right = state[sti->right].left = i; sti->color ^= (sti->left == i-1); // check color assumption } if (type & 1) stack[sp++] = i; leftcolor = sti->color; } } int main() { bstate state; Word_t s = 0675; wordtostate(s, 0, state); printf("%s\n", state[1].color ? "OK" : "BUG"); return 0; } -- Summary: Optimizations -fcse-follow-jumps -fforce-mem break code Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tromp at cwi dot nl http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24361