re PR tree-optimization/65241 (ICE (in remove_local_expressions_from_table, at tree...
authorJeff Law <law@redhat.com>
Tue, 3 Mar 2015 11:54:49 +0000 (04:54 -0700)
committerJeff Law <law@gcc.gnu.org>
Tue, 3 Mar 2015 11:54:49 +0000 (04:54 -0700)
PR tree-optimization/65241
* tree-ssa-dom.c (lookup_avail_expr): Only modify the avail_expr
hash table if INSERT is true.

PR tree-optimization/65241
* gcc.c-torture/compile/pr65241.c: New test.

From-SVN: r221145

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr65241.c [new file with mode: 0644]
gcc/tree-ssa-dom.c

index 55c106c3f7681a44d68ea8e2f11d9c58262db925..cb42917f6104aa86179b1f886a23d1ab614d5f46 100644 (file)
@@ -1,3 +1,9 @@
+2015-03-23  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/65241
+       * tree-ssa-dom.c (lookup_avail_expr): Only modify the avail_expr
+       hash table if INSERT is true.
+
 2015-03-03  Georg-Johann Lay  <avr@gjlay.de>
 
        PR target/65296
index ecc4cc42b3134ff227d26b67b222d42a1a65f527..824d2561fea38bfbf1afd357ab275a5dc3b46305 100644 (file)
@@ -1,3 +1,8 @@
+2015-03-13  Jeff Law  <law@redhat.com>
+
+       PR tree-optimization/65241
+       * gcc.c-torture/compile/pr65241.c: New test.
+
 2015-03-03  Georg-Johann Lay  <avr@gjlay.de>
 
        PR target/64331
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr65241.c b/gcc/testsuite/gcc.c-torture/compile/pr65241.c
new file mode 100644 (file)
index 0000000..dd76ac5
--- /dev/null
@@ -0,0 +1,26 @@
+enum E { A, B, C, D };
+void fn4 (void);
+
+int
+fn1 (enum E p1)
+{
+  static int w[D];
+  if (w[p1])
+    switch (p1)
+      case C:
+      w[p1] = 0;
+}
+
+void
+fn2 (p1)
+{
+  fn1 (p1);
+}
+
+void
+fn3 (enum E p1)
+{
+  fn2 (p1);
+  fn4 ();
+  fn2 (p1);
+}
index 096e4712675d0b9af66287a6e4edd19a33998cb3..d230ce1c7b38637ce539a86f9c3f46206a04b501 100644 (file)
@@ -2649,19 +2649,22 @@ lookup_avail_expr (gimple stmt, bool insert)
            && walk_non_aliased_vuses (&ref, vuse2,
                                       vuse_eq, NULL, NULL, vuse1) != NULL))
        {
-         struct expr_hash_elt *element2 = XNEW (struct expr_hash_elt);
-         *element2 = element;
-         element2->stamp = element2;
-
-         /* Insert the expr into the hash by replacing the current
-            entry and recording the value to restore in the
-            aval_exprs_stack.  */
-         avail_exprs_stack.safe_push (std::make_pair (element2, *slot));
-         *slot = element2;
-         if (dump_file && (dump_flags & TDF_DETAILS))
+         if (insert)
            {
-             fprintf (dump_file, "2>>> ");
-             print_expr_hash_elt (dump_file, *slot);
+             struct expr_hash_elt *element2 = XNEW (struct expr_hash_elt);
+             *element2 = element;
+             element2->stamp = element2;
+
+             /* Insert the expr into the hash by replacing the current
+                entry and recording the value to restore in the
+                avail_exprs_stack.  */
+             avail_exprs_stack.safe_push (std::make_pair (element2, *slot));
+             *slot = element2;
+             if (dump_file && (dump_flags & TDF_DETAILS))
+               {
+                 fprintf (dump_file, "2>>> ");
+                 print_expr_hash_elt (dump_file, *slot);
+               }
            }
          return NULL_TREE;
        }