[Bug tree-optimization/69776] [4.9/5 Regression] Wrong optimization with aliasing
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69776 --- Comment #13 from Richard Biener --- Author: rguenth Date: Thu Feb 25 09:07:08 2016 New Revision: 233693 URL: https://gcc.gnu.org/viewcvs?rev=233693&root=gcc&view=rev Log: 2016-02-25 Richard Biener Backport from mainline 2016-02-15 Richard Biener PR tree-optimization/69776 * tree-ssa-sccvn.h (vn_reference_lookup): Adjust prototype. * tree-ssa-sccvn.c (vn_reference_lookup): Add parameter to indicate whether we can use TBAA to disambiguate against stores. Use alias-set zero if not. (visit_reference_op_store): Do not use TBAA when looking up redundant stores. * tree-ssa-pre.c (compute_avail): Use TBAA here. (eliminate_dom_walker::before_dom_children): But not when looking up redundant stores. * gcc.dg/torture/pr69776.c: New testcase. 2016-02-16 Richard Biener PR tree-optimization/69776 * tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Get alias sets from caller. (indirect_refs_may_alias_p): Likewise. (refs_may_alias_p_1): Pass alias sets as from ao_ref. * tree-ssa-sccvn.c (vn_reference_lookup): Also adjust vr alias-set according to tbaa_p. * tree-ssa-dom.c (lookup_avail_expr): Add tbaa_p flag. (optimize_stmt): For redundant store discovery do not allow tbaa. * gcc.dg/torture/pr69776-2.c: New testcase. Added: branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr69776-2.c branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr69776.c Modified: branches/gcc-5-branch/gcc/ChangeLog branches/gcc-5-branch/gcc/testsuite/ChangeLog branches/gcc-5-branch/gcc/tree-ssa-alias.c branches/gcc-5-branch/gcc/tree-ssa-dom.c branches/gcc-5-branch/gcc/tree-ssa-pre.c branches/gcc-5-branch/gcc/tree-ssa-sccvn.c branches/gcc-5-branch/gcc/tree-ssa-sccvn.h
[Bug tree-optimization/69776] [4.9/5 Regression] Wrong optimization with aliasing
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69776 --- Comment #12 from Alexander Cherepanov --- Seems to be fixed, thanks! I've tried several variations, ok too.
[Bug tree-optimization/69776] [4.9/5 Regression] Wrong optimization with aliasing
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69776 --- Comment #11 from Richard Biener --- Now hopefully fixed on trunk.
[Bug tree-optimization/69776] [4.9/5 Regression] Wrong optimization with aliasing
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69776 --- Comment #10 from Richard Biener --- Author: rguenth Date: Tue Feb 16 15:00:45 2016 New Revision: 233453 URL: https://gcc.gnu.org/viewcvs?rev=233453&root=gcc&view=rev Log: 2016-02-16 Richard Biener PR tree-optimization/69776 * tree-ssa-alias.c (indirect_ref_may_alias_decl_p): Get alias sets from caller. (indirect_refs_may_alias_p): Likewise. (refs_may_alias_p_1): Pass alias sets as from ao_ref. * tree-ssa-sccvn.c (vn_reference_lookup): Also adjust vr alias-set according to tbaa_p. * tree-ssa-dom.c (lookup_avail_expr): Add tbaa_p flag. (optimize_stmt): For redundant store discovery do not allow tbaa. * gcc.dg/torture/pr69776-2.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/torture/pr69776-2.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-ssa-alias.c trunk/gcc/tree-ssa-dom.c trunk/gcc/tree-ssa-sccvn.c
[Bug tree-optimization/69776] [4.9/5 Regression] Wrong optimization with aliasing
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69776 --- Comment #9 from Richard Biener --- Looks like the fix was too constrained. I have a patch to fix it some more.
[Bug tree-optimization/69776] [4.9/5 Regression] Wrong optimization with aliasing
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69776 --- Comment #8 from Alexander Cherepanov --- --- Comment #4 from Richard Biener --- > Actually the middle-end memory model makes this valid and FREs redundant store > elimination breaks it. And function boundaries are not an obstacle for validity? I guess so (as gcc devs expressed such views several times in the past, in various contexts) but I'm not sure because DR 236 states otherwise. Initial testcase was prepared not to trigger DR 236 and, thus, it's a bit more tricky than necessary. --- Comment #7 from Richard Biener --- > Fixed on trunk sofar. While the reduced testcase seems to be fixed, the original testcase still fails for me. If a separate function is ok the following testcase should be easier to reason about: extern void *malloc (__SIZE_TYPE__); extern void abort (void); __attribute__((noinline,noclone)) void f(int *qi, double *qd) { int i = *qi; *qd = 0; *qi = i; } int main() { int *p = malloc(sizeof(double)); *p = 1; f(p, (double *)p); if (*p != 1) abort(); } This bug report was really about optimization of the function f in the absence of additional info, e.g. when compiled in a separate TU. (noinline+noclone seem to be enough too.) All printfs in the original testcase are just to achieve the same outcome without explicit function. But maybe I accidentally triggered another gcc bug. BTW your testcase in comment #5 is interesting because the implementation of the function foo seems to affect the optimization of the rest of the program, i.e. noinline+noclone provide only one-way isolation. Just last week I asked about it elsewhere and here it is. Thanks! :-)
[Bug tree-optimization/69776] [4.9/5 Regression] Wrong optimization with aliasing
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69776 Richard Biener changed: What|Removed |Added Known to work||6.0 Summary|[4.9/5/6 Regression] Wrong |[4.9/5 Regression] Wrong |optimization with aliasing |optimization with aliasing --- Comment #7 from Richard Biener --- Fixed on trunk sofar.