Summary: | [4.8 Regression] wrong code at -O3 on x86_64-linux-gnu | ||
---|---|---|---|
Product: | gcc | Reporter: | Zhendong Su <su> |
Component: | tree-optimization | Assignee: | Richard Biener <rguenth> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | jakub |
Priority: | P3 | Keywords: | wrong-code |
Version: | 6.0 | ||
Target Milestone: | 4.9.3 | ||
Host: | Target: | ||
Build: | Known to work: | 4.9.3, 5.2.0, 6.0 | |
Known to fail: | 4.9.2, 5.1.0 | Last reconfirmed: | 2015-05-24 00:00:00 |
Description
Zhendong Su
2015-05-24 10:02:26 UTC
The testcase can be simplified a bit (I eliminated variable c and moved array a inside main, so it's now local). struct S { int f0; int f1; }; int b; int main () { struct S a[2] = { 0 }; struct S d = { 0, 1 }; for (b = 0; b < 2; b++) { a[b] = d; d = a[0]; } if (d.f1 != 1) __builtin_abort (); } Wrong transformation is made in predictive commoning pass (the program compiled with -O3 -fno-predictive-commoning does not abort). The store d.f1 = a[0].f1; is assumed to be independent of the previous store to a[b] (which is obviously wrong) and it is hoisted out of the loop. I think the reason is that find_data_references_in_stmt or some related function misenterprets MEM[(struct S[2] *)&a + 4B] as some object that does not alias with MEM[(struct S *)&a]'s SCEV. By the way, the expression itself looks strange: struct S * should be "a", not "&a". (Data Dep: #(Data Ref: # bb: 3 # stmt: MEM[(struct S *)_4 + 4B] = d$f1_7; # ref: MEM[(struct S *)_4 + 4B]; # base_object: MEM[(struct S *)&a]; # Access function 0: {4B, +, 8}_1 #) #(Data Ref: # bb: 3 # stmt: d$f1_16 = MEM[(struct S[2] *)&a + 4B]; # ref: MEM[(struct S[2] *)&a + 4B]; # base_object: MEM[(struct S[2] *)&a + 4B]; #) (no dependence) ) If I scalarize the assignment d = a[0] (I mean, in the source), the bug disappears. Bah, mine. Author: rguenth Date: Wed May 27 14:20:48 2015 New Revision: 223759 URL: https://gcc.gnu.org/viewcvs?rev=223759&root=gcc&view=rev Log: 2015-05-27 Richard Biener <rguenther@suse.de> PR tree-optimization/66272 Revert parts of 2014-08-15 Richard Biener <rguenther@suse.de> PR tree-optimization/62031 * tree-data-ref.c (dr_analyze_indices): Do not set DR_UNCONSTRAINED_BASE. (dr_may_alias_p): All indirect accesses have to go the formerly DR_UNCONSTRAINED_BASE path. * tree-data-ref.h (struct indices): Remove unconstrained_base member. (DR_UNCONSTRAINED_BASE): Remove. * gcc.dg/torture/pr66272.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/torture/pr66272.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-data-ref.c trunk/gcc/tree-data-ref.h Fixed on trunk sofar. Author: rguenth Date: Wed Jun 3 07:39:06 2015 New Revision: 224059 URL: https://gcc.gnu.org/viewcvs?rev=224059&root=gcc&view=rev Log: 2015-06-03 Richard Biener <rguenther@suse.de> Backport from mainline 2015-06-02 Richard Biener <rguenther@suse.de> PR debug/65549 * dwarf2out.c (lookup_context_die): New function. (resolve_addr): Avoid forcing a full DIE for the target of a DW_TAG_GNU_call_site during late compilation. Instead create a stub DIE without a type if we have a context DIE present. * g++.dg/lto/pr65549_0.C: New testcase. 2015-06-01 Richard Biener <rguenther@suse.de> PR tree-optimization/66280 * tree-vect-slp.c (vect_detect_hybrid_slp_stmts): Fix pattern def-use walking. * g++.dg/torture/pr66280.C: New testcase. * g++.dg/torture/pr66280-2.C: Likewise. 2015-05-27 Richard Biener <rguenther@suse.de> PR tree-optimization/66272 Revert parts of 2014-08-15 Richard Biener <rguenther@suse.de> PR tree-optimization/62031 * tree-data-ref.c (dr_analyze_indices): Do not set DR_UNCONSTRAINED_BASE. (dr_may_alias_p): All indirect accesses have to go the formerly DR_UNCONSTRAINED_BASE path. * tree-data-ref.h (struct indices): Remove unconstrained_base member. (DR_UNCONSTRAINED_BASE): Remove. * gcc.dg/torture/pr66272.c: New testcase. 2015-05-21 Richard Biener <rguenther@suse.de> PR c++/66211 * match.pd: Guard pattern optimzing (int)(float)int conversions to apply only on GIMPLE. * g++.dg/conversion/pr66211.C: New testcase. * gcc.dg/tree-ssa/forwprop-18.c: Adjust. 2015-05-13 Richard Biener <rguenther@suse.de> PR tree-optimization/66123 * tree-ssa-dom.c (propagate_rhs_into_lhs): Check if we found a taken edge. * gcc.dg/torture/pr66123.c: New testcase. Added: branches/gcc-5-branch/gcc/testsuite/g++.dg/conversion/pr66211.C branches/gcc-5-branch/gcc/testsuite/g++.dg/lto/pr65549_0.C branches/gcc-5-branch/gcc/testsuite/g++.dg/torture/pr66280-2.C branches/gcc-5-branch/gcc/testsuite/g++.dg/torture/pr66280.C branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr66123.c branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr66272.c Modified: branches/gcc-5-branch/gcc/ChangeLog branches/gcc-5-branch/gcc/dwarf2out.c branches/gcc-5-branch/gcc/match.pd branches/gcc-5-branch/gcc/testsuite/ChangeLog branches/gcc-5-branch/gcc/testsuite/gcc.dg/tree-ssa/forwprop-18.c branches/gcc-5-branch/gcc/tree-data-ref.c branches/gcc-5-branch/gcc/tree-data-ref.h branches/gcc-5-branch/gcc/tree-ssa-dom.c branches/gcc-5-branch/gcc/tree-vect-slp.c Author: rguenth Date: Wed Jun 3 11:03:26 2015 New Revision: 224072 URL: https://gcc.gnu.org/viewcvs?rev=224072&root=gcc&view=rev Log: 2015-06-03 Richard Biener <rguenther@suse.de> Backport from mainline 2015-05-26 Michael Matz <matz@suse.de> PR middle-end/66251 * tree-vect-stmts.c (vect_create_vectorized_demotion_stmts): Always set STMT_VINFO_VEC_STMT, also with SLP. * gcc.dg/vect/pr66251.c: New test. 2015-05-22 Richard Biener <rguenther@suse.de> PR tree-optimization/66251 * tree-vect-stmts.c (vectorizable_conversion): Properly set STMT_VINFO_VEC_STMT even for the SLP case. * gfortran.fortran-torture/compile/pr66251.f90: New testcase. 2015-05-27 Richard Biener <rguenther@suse.de> PR tree-optimization/66272 Revert parts of 2014-08-15 Richard Biener <rguenther@suse.de> PR tree-optimization/62031 * tree-data-ref.c (dr_analyze_indices): Do not set DR_UNCONSTRAINED_BASE. (dr_may_alias_p): All indirect accesses have to go the formerly DR_UNCONSTRAINED_BASE path. * tree-data-ref.h (struct indices): Remove unconstrained_base member. (DR_UNCONSTRAINED_BASE): Remove. * gcc.dg/torture/pr66272.c: New testcase. 2015-05-13 Richard Biener <rguenther@suse.de> PR tree-optimization/66123 * tree-ssa-dom.c (propagate_rhs_into_lhs): Check if we found a taken edge. * gcc.dg/torture/pr66123.c: New testcase. 2015-06-02 Richard Biener <rguenther@suse.de> PR debug/65549 * dwarf2out.c (lookup_context_die): New function. (resolve_addr): Avoid forcing a full DIE for the target of a DW_TAG_GNU_call_site during late compilation. Instead create a stub DIE without a type if we have a context DIE present. * g++.dg/lto/pr65549_0.C: New testcase. 2015-03-23 Richard Biener <rguenther@suse.de> PR tree-optimization/65518 * tree-vect-stmts.c (vectorizable_load): Reject single-element interleaving cases we generate absymal code for. * gcc.dg/vect/pr65518.c: New testcase. Added: branches/gcc-4_9-branch/gcc/testsuite/g++.dg/lto/pr65549_0.C branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/torture/pr66123.c branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/torture/pr66272.c branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr65518.c branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/vect/pr66251.c branches/gcc-4_9-branch/gcc/testsuite/gfortran.fortran-torture/compile/pr66251.f90 Modified: branches/gcc-4_9-branch/gcc/ChangeLog branches/gcc-4_9-branch/gcc/dwarf2out.c branches/gcc-4_9-branch/gcc/testsuite/ChangeLog branches/gcc-4_9-branch/gcc/tree-data-ref.c branches/gcc-4_9-branch/gcc/tree-data-ref.h branches/gcc-4_9-branch/gcc/tree-ssa-dom.c branches/gcc-4_9-branch/gcc/tree-vect-stmts.c Author: rguenth Date: Wed Jun 3 13:50:11 2015 New Revision: 224081 URL: https://gcc.gnu.org/viewcvs?rev=224081&root=gcc&view=rev Log: 2015-06-03 Richard Biener <rguenther@suse.de> Backport from mainline 2015-05-26 Michael Matz <matz@suse.de> PR middle-end/66251 * tree-vect-stmts.c (vect_create_vectorized_demotion_stmts): Always set STMT_VINFO_VEC_STMT, also with SLP. * gcc.dg/vect/pr66251.c: New test. 2015-05-22 Richard Biener <rguenther@suse.de> PR tree-optimization/66251 * tree-vect-stmts.c (vectorizable_conversion): Properly set STMT_VINFO_VEC_STMT even for the SLP case. * gfortran.fortran-torture/compile/pr66251.f90: New testcase. 2015-03-23 Richard Biener <rguenther@suse.de> PR tree-optimization/65518 * tree-vect-stmts.c (vectorizable_load): Reject single-element interleaving cases we generate absymal code for. * gcc.dg/vect/pr65518.c: New testcase. 2015-05-13 Richard Biener <rguenther@suse.de> PR tree-optimization/66123 * tree-ssa-dom.c (propagate_rhs_into_lhs): Check if we found a taken edge. * gcc.dg/torture/pr66123.c: New testcase. 2015-05-27 Richard Biener <rguenther@suse.de> PR tree-optimization/66272 Revert parts of 2014-08-15 Richard Biener <rguenther@suse.de> PR tree-optimization/62031 * tree-data-ref.c (dr_analyze_indices): Do not set DR_UNCONSTRAINED_BASE. (dr_may_alias_p): All indirect accesses have to go the formerly DR_UNCONSTRAINED_BASE path. * tree-data-ref.h (struct indices): Remove unconstrained_base member. (DR_UNCONSTRAINED_BASE): Remove. * gcc.dg/torture/pr66272.c: New testcase. Added: branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr66123.c branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/torture/pr66272.c branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/vect/pr65518.c branches/gcc-4_8-branch/gcc/testsuite/gcc.dg/vect/pr66251.c branches/gcc-4_8-branch/gcc/testsuite/gfortran.fortran-torture/compile/pr66251.f90 Modified: branches/gcc-4_8-branch/gcc/ChangeLog branches/gcc-4_8-branch/gcc/testsuite/ChangeLog branches/gcc-4_8-branch/gcc/tree-data-ref.c branches/gcc-4_8-branch/gcc/tree-data-ref.h branches/gcc-4_8-branch/gcc/tree-ssa-dom.c branches/gcc-4_8-branch/gcc/tree-vect-stmts.c Fixed. |