re PR tree-optimization/78218 (wrong code at -Os and above on x86_64-linux-gnu (in...
authorRichard Biener <rguenther@suse.de>
Mon, 7 Nov 2016 12:26:00 +0000 (12:26 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 7 Nov 2016 12:26:00 +0000 (12:26 +0000)
2016-11-07  Richard Biener  <rguenther@suse.de>

PR tree-optimization/78218
* gimple-ssa-store-merging.c
(pass_store_merging::terminate_all_aliasing_chains):
Drop unused argument, fix alias check to also consider uses.
(pass_store_merging::execute): Adjust.

* gcc.dg/torture/pr78218.c: New testcase.

From-SVN: r241900

gcc/ChangeLog
gcc/gimple-ssa-store-merging.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr78218.c [new file with mode: 0644]

index 262f0068b488905de73814e722f5aa011b676013..5ccd3b4ca62ca447a9b2d2e321deb72bef8f415f 100644 (file)
@@ -1,3 +1,11 @@
+2016-11-07  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/78218
+       * gimple-ssa-store-merging.c
+       (pass_store_merging::terminate_all_aliasing_chains):
+       Drop unused argument, fix alias check to also consider uses.
+       (pass_store_merging::execute): Adjust.
+
 2016-11-07  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/78228
index 36bc833af910f85c4c8ed7581a247f5d3182053d..57b855671dbbda59c206403ce3adb4acf65a3cad 100644 (file)
@@ -726,7 +726,7 @@ private:
   hash_map<tree_operand_hash, struct imm_store_chain_info *> m_stores;
 
   bool terminate_and_process_all_chains ();
-  bool terminate_all_aliasing_chains (tree, imm_store_chain_info **,
+  bool terminate_all_aliasing_chains (imm_store_chain_info **,
                                      bool, gimple *);
   bool terminate_and_release_chain (imm_store_chain_info *);
 }; // class pass_store_merging
@@ -755,8 +755,7 @@ pass_store_merging::terminate_and_process_all_chains ()
    If that is the case we have to terminate any chain anchored at BASE.  */
 
 bool
-pass_store_merging::terminate_all_aliasing_chains (tree dest,
-                                                  imm_store_chain_info
+pass_store_merging::terminate_all_aliasing_chains (imm_store_chain_info
                                                     **chain_info,
                                                   bool var_offset_p,
                                                   gimple *stmt)
@@ -788,7 +787,10 @@ pass_store_merging::terminate_all_aliasing_chains (tree dest,
          unsigned int i;
          FOR_EACH_VEC_ELT ((*chain_info)->m_store_info, i, info)
            {
-             if (stmt_may_clobber_ref_p (info->stmt, dest))
+             if (ref_maybe_used_by_stmt_p (stmt,
+                                           gimple_assign_lhs (info->stmt))
+                 || stmt_may_clobber_ref_p (stmt,
+                                            gimple_assign_lhs (info->stmt)))
                {
                  if (dump_file && (dump_flags & TDF_DETAILS))
                    {
@@ -1458,7 +1460,7 @@ pass_store_merging::execute (function *fun)
                    }
 
                  /* Store aliases any existing chain?  */
-                 terminate_all_aliasing_chains (lhs, chain_info, false, stmt);
+                 terminate_all_aliasing_chains (chain_info, false, stmt);
                  /* Start a new chain.  */
                  struct imm_store_chain_info *new_chain
                    = new imm_store_chain_info (base_addr);
@@ -1477,13 +1479,13 @@ pass_store_merging::execute (function *fun)
                    }
                }
              else
-               terminate_all_aliasing_chains (lhs, chain_info,
+               terminate_all_aliasing_chains (chain_info,
                                               offset != NULL_TREE, stmt);
 
              continue;
            }
 
-         terminate_all_aliasing_chains (NULL_TREE, NULL, false, stmt);
+         terminate_all_aliasing_chains (NULL, false, stmt);
        }
       terminate_and_process_all_chains ();
     }
index 0dff659bda47ddaf3bcc2e509def033b95c3f642..242b51b3764ba964b9d5749ce6edefd9f41d65a6 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-07  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/78218
+       * gcc.dg/torture/pr78218.c: New testcase.
+
 2016-11-07  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/78228
diff --git a/gcc/testsuite/gcc.dg/torture/pr78218.c b/gcc/testsuite/gcc.dg/torture/pr78218.c
new file mode 100644 (file)
index 0000000..b3e2892
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do run } */
+
+struct 
+{
+  int v;
+} a[2];
+
+int b; 
+
+void __attribute__((noinline,noclone))
+check ()
+{
+  if (a[0].v != 1)
+    __builtin_abort ();
+}
+
+int main ()
+{
+  a[1].v = 1;
+  a[0] = a[1];
+  a[1].v = 0;
+  check (a);
+  return 0;
+}