The current gcc trunk miscompiles the following testcase on x86_64-linux-gnu at -O3 (in both 32-bit and 64-bit modes). This is a regression from 4.8.x. $ gcc-trunk -v Using built-in specs. COLLECT_GCC=gcc-trunk COLLECT_LTO_WRAPPER=/usr/local/gcc-trunk/libexec/gcc/x86_64-unknown-linux-gnu/4.9.0/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../gcc-trunk/configure --enable-languages=c,c++,objc,obj-c++,fortran,lto --disable-werror --enable-checking=release --with-gmp=/usr/local/gcc-trunk --with-mpfr=/usr/local/gcc-trunk --with-mpc=/usr/local/gcc-trunk --with-cloog=/usr/local/gcc-trunk --prefix=/usr/local/gcc-trunk Thread model: posix gcc version 4.9.0 20131108 (experimental) [trunk revision 204560] (GCC) $ $ gcc-trunk -O2 small.c; a.out 1 $ gcc-4.8.2 -O3 small.c; a.out 1 $ $ gcc-trunk -O3 small.c; a.out 0 $ -------------------------------------- int printf (const char *, ...); struct { int f0; int f1:1; int f2:2; } a = {0, 0, 1}; int b, c, *d, e, f; int fn1 () { for (; b < 1; ++b) { for (e = 0; e < 1; e = 1) { int **g = &d; *g = &c; } *d = 0; f = a.f1; if (f) return 0; } return 0; } int main () { fn1 (); printf ("%d\n", b); return 0; }
Confirmed.
Triggered by predictive commoning fix. Mine.
Author: rguenth Date: Fri Nov 8 12:49:10 2013 New Revision: 204566 URL: http://gcc.gnu.org/viewcvs?rev=204566&root=gcc&view=rev Log: 2013-11-08 Richard Biener <rguenther@suse.de> PR tree-optimization/59047 * tree-predcom.c (ref_at_iteration): Handle bitfield accesses properly. * gcc.dg/torture/pr59047.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/torture/pr59047.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-predcom.c
Fixed.
Author: rguenth Date: Mon Nov 18 15:13:14 2013 New Revision: 204965 URL: http://gcc.gnu.org/viewcvs?rev=204965&root=gcc&view=rev Log: 2013-11-18 Richard Biener <rguenther@suse.de> Backport from mainline 2013-10-21 Richard Biener <rguenther@suse.de> PR tree-optimization/58794 * fold-const.c (operand_equal_p): Compare FIELD_DECL operand of COMPONENT_REFs with OEP_CONSTANT_ADDRESS_OF left in place. * c-c++-common/torture/pr58794-1.c: New testcase. * c-c++-common/torture/pr58794-2.c: Likewise. 2013-10-21 Richard Biener <rguenther@suse.de> PR middle-end/58742 * fold-const.c (fold_binary_loc): Fold ((T) (X /[ex] C)) * C to (T) X for sign-changing conversions (or no conversion). * c-c++-common/fold-divmul-1.c: New testcase. 2013-11-06 Richard Biener <rguenther@suse.de> PR tree-optimization/58653 * tree-predcom.c (ref_at_iteration): Rewrite to generate a MEM_REF. (prepare_initializers_chain): Adjust. * gcc.dg/tree-ssa/predcom-6.c: New testcase. * gcc.dg/tree-ssa/predcom-7.c: Likewise. PR tree-optimization/59047 * tree-predcom.c (ref_at_iteration): Handle bitfield accesses properly. * gcc.dg/torture/pr59047.c: New testcase. 2013-10-15 Richard Biener <rguenther@suse.de> PR tree-optimization/58143 * tree-ssa-loop-im.c (arith_code_with_undefined_signed_overflow): New function. (rewrite_to_defined_overflow): Likewise. (move_computations_dom_walker::before_dom): Rewrite stmts with undefined signed overflow that are not always executed into unsigned arithmetic. * gcc.dg/torture/pr58143-1.c: New testcase. * gcc.dg/torture/pr58143-2.c: Likewise. * gcc.dg/torture/pr58143-3.c: Likewise. Added: branches/gcc-4_8-branch/gcc/testsuite/c-c++-common/fold-divmul-1.c branches/gcc-4_8-branch/gcc/testsuite/c-c++-common/torture/pr58794-1.c branches/gcc-4_8-branch/gcc/testsuite/c-c++-common/torture/pr58794-2.c branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr58143-1.c branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr58143-2.c branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr58143-3.c branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr59047.c branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/tree-ssa/predcom-6.c branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/tree-ssa/predcom-7.c Modified: branches/gcc-4_8-branch/gcc/ChangeLog branches/gcc-4_8-branch/gcc/fold-const.c branches/gcc-4_8-branch/gcc/testsuite/ChangeLog branches/gcc-4_8-branch/gcc/tree-predcom.c branches/gcc-4_8-branch/gcc/tree-ssa-loop-im.c