re PR tree-optimization/62238 (ICE with LTO on valid code on x86_64-linux-gnu in...
authorRichard Biener <rguenther@suse.de>
Wed, 26 Nov 2014 09:43:39 +0000 (09:43 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 26 Nov 2014 09:43:39 +0000 (09:43 +0000)
2014-11-26  Richard Biener  <rguenther@suse.de>

PR tree-optimization/62238
* tree-predcom.c (ref_at_iteration): Unshare the expression
before gimplifying it.
(prepare_initializers_chain): Discard unused seq.

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

From-SVN: r218074

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr62238.c [new file with mode: 0644]
gcc/tree-predcom.c

index adc31461af16a10cbfdd2d5b7023251a4f9073d6..14fc5b90f1c26e114c092c460279f775a6374317 100644 (file)
@@ -1,3 +1,10 @@
+2014-11-26  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/62238
+       * tree-predcom.c (ref_at_iteration): Unshare the expression
+       before gimplifying it.
+       (prepare_initializers_chain): Discard unused seq.
+
 2014-11-25  Vladimir Makarov  <vmakarov@redhat.com>
 
        * ira-lives.c (process_bb_node_lives): Make code with conditional
index cc579801f342f3124babfdad7d5dbc3ff6a7930d..adc868ff2335988cece9db4dc51ff6a751aec0a0 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-26  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/62238
+       * gcc.dg/torture/pr62238.c: New testcase.
+
 2014-11-25  Andrew Pinski <apinski@cavium.com>
 
        * gcc.c-torture/execute/20141125-1.c: New testcase.
diff --git a/gcc/testsuite/gcc.dg/torture/pr62238.c b/gcc/testsuite/gcc.dg/torture/pr62238.c
new file mode 100644 (file)
index 0000000..de8951a
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+
+int a[4], b, c, d; 
+
+int
+fn1 (int p)
+{
+  for (; d; d++)
+    {
+      unsigned int h;
+      for (h = 0; h < 3; h++)
+       {
+         if (a[c+c+h])
+           {
+             if (p)
+               break;
+             return 0;
+           }
+         b = 0;
+       }
+    }
+  return 0;
+}
+
+int
+main ()
+{
+  fn1 (0);
+  return 0;
+}
index 93a523ca2ca430ebf94d05f56a3a3cccd834e89c..230c5c08fe6039493b4d1e2f5dd071b16cd1533b 100644 (file)
@@ -1402,8 +1402,8 @@ ref_at_iteration (data_reference_p dr, int iter, gimple_seq *stmts)
     off = size_binop (PLUS_EXPR, off,
                      size_binop (MULT_EXPR, DR_STEP (dr), ssize_int (iter)));
   tree addr = fold_build_pointer_plus (DR_BASE_ADDRESS (dr), off);
-  addr = force_gimple_operand_1 (addr, stmts, is_gimple_mem_ref_addr,
-                                NULL_TREE);
+  addr = force_gimple_operand_1 (unshare_expr (addr), stmts,
+                                is_gimple_mem_ref_addr, NULL_TREE);
   tree alias_ptr = fold_convert (reference_alias_ptr_type (DR_REF (dr)), coff);
   /* While data-ref analysis punts on bit offsets it still handles
      bitfield accesses at byte boundaries.  Cope with that.  Note that
@@ -2354,7 +2354,6 @@ prepare_initializers_chain (struct loop *loop, chain_p chain)
   unsigned i, n = (chain->type == CT_INVARIANT) ? 1 : chain->length;
   struct data_reference *dr = get_chain_root (chain)->ref;
   tree init;
-  gimple_seq stmts;
   dref laref;
   edge entry = loop_preheader_edge (loop);
 
@@ -2378,12 +2377,17 @@ prepare_initializers_chain (struct loop *loop, chain_p chain)
 
   for (i = 0; i < n; i++)
     {
+      gimple_seq stmts = NULL;
+
       if (chain->inits[i] != NULL_TREE)
        continue;
 
       init = ref_at_iteration (dr, (int) i - n, &stmts);
       if (!chain->all_always_accessed && tree_could_trap_p (init))
-       return false;
+       {
+         gimple_seq_discard (stmts);
+         return false;
+       }
 
       if (stmts)
        gsi_insert_seq_on_edge_immediate (entry, stmts);