https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93745
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Redundant store not |[8/9/10 Regression] |eliminated with |Redundant store not |intermediate instruction |eliminated with | |intermediate instruction --- Comment #5 from Martin Sebor <msebor at gcc dot gnu.org> --- In the example p cannot point to d because of the assignment i=*p which would be undefined if it did. Other compilers (Clang an ICC) eliminate the accesses via *p and emit optimal code, as do versions of GCC prior to 6, so this seems like an unnecessary pessimization. Bisection points to r233453 which deals with allocated objects, which are the only kind of objects whose type can change in C. But I'll let Richard confirm whether this is necessary for some reason. commit 87440c298eb2ed47166b8d57a4afc90d310f3a8f Author: Richard Biener <rguent...@suse.de> Date: Tue Feb 16 15:00:45 2016 +0000 re PR tree-optimization/69776 (Wrong optimization with aliasing) 2016-02-16 Richard Biener <rguent...@suse.de> 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. From-SVN: r233453 Since GCC eliminates the test in the modified example below it must assume that p doesn't point to d, and so it should likewise be able to eliminate the *p=i assignment as Marc expects. double d; void f(long*p){ long i=*p; d=3.; if (*p != i) // folded to false abort (); }