]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-ssa-pre.c (valid_in_sets): Remove checking of trapping operations.
authorRichard Guenther <rguenther@suse.de>
Thu, 3 May 2012 13:07:31 +0000 (13:07 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 3 May 2012 13:07:31 +0000 (13:07 +0000)
2012-05-03  Richard Guenther  <rguenther@suse.de>

* tree-ssa-pre.c (valid_in_sets): Remove checking of trapping
operations.
(prune_clobbered_mems): Do it here.  Do not uselessly sort
expressions.
(compute_avail): Do not add possibly trapping operations to
EXP_GEN if they might not be executed in the block.

* gcc.dg/tree-ssa/ssa-pre-27.c: Remove XFAIL.

From-SVN: r187096

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/ssa-pre-27.c
gcc/tree-ssa-pre.c

index 1bff6dee2892e24695e35a82f6234abbbb5f6aec..7b523a661356f1178a32511340fe8d4746a627d8 100644 (file)
@@ -1,3 +1,12 @@
+2012-05-03  Richard Guenther  <rguenther@suse.de>
+
+       * tree-ssa-pre.c (valid_in_sets): Remove checking of trapping
+       operations.
+       (prune_clobbered_mems): Do it here.  Do not uselessly sort
+       expressions.
+       (compute_avail): Do not add possibly trapping operations to
+       EXP_GEN if they might not be executed in the block.
+
 2012-05-03  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/alpha/elf.h (MAX_OFILE_ALIGNMENT): Remove.
index a642d17b8f03e5f388f94b18b4a959339c034c9a..c35bd8523abdecf4fb083bb2568531c8440223d4 100644 (file)
@@ -1,3 +1,7 @@
+2012-05-03  Richard Guenther  <rguenther@suse.de>
+
+       * gcc.dg/tree-ssa/ssa-pre-27.c: Remove XFAIL.
+
 2012-05-03  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/hle-cmpxchg-acq-1.c (dg-options): Add -march=x86-64.
index 1d60a30132076262bf4d0d923938bd114eb9d740..4149bbef6a5d8f806dde67ab83e5c3b357824dff 100644 (file)
@@ -17,13 +17,12 @@ int foo2 (int i, int j, int b)
   int res = 0;
   if (b)
     res = i/j;
-  /* But we fail so here because of the possibly not returning
-     call in the same basic-block.  */
+  /* And here, the possibly not returning call in the same basic-block
+     comes after the trapping i/j.  */
   res += i/j;
   bar ();
   return res;
 }
 
-/* { dg-final { scan-tree-dump-times "# prephitmp" 1 "pre" } } */
-/* { dg-final { scan-tree-dump-times "# prephitmp" 2 "pre" { xfail *-*-* } } } */
+/* { dg-final { scan-tree-dump-times "# prephitmp" 2 "pre" } } */
 /* { dg-final { cleanup-tree-dump "pre" } } */
index e27e91471ca252c7d07ec6307c54f3b15ccc4734..776a37cdcc6ea00dc969485a5713cda50e1adcd7 100644 (file)
@@ -2069,13 +2069,6 @@ valid_in_sets (bitmap_set_t set1, bitmap_set_t set2, pre_expr expr,
        for (i = 0; i < nary->length; i++)
          if (!op_valid_in_sets (set1, set2, nary->op[i]))
            return false;
-       /* If the NARY may trap make sure the block does not contain
-          a possible exit point.
-          ???  This is overly conservative if we translate AVAIL_OUT
-          as the available expression might be after the exit point.  */
-       if (BB_MAY_NOTRETURN (block)
-           && vn_nary_may_trap (nary))
-         return false;
        return true;
       }
       break;
@@ -2140,35 +2133,44 @@ clean (bitmap_set_t set, basic_block block)
 }
 
 /* Clean the set of expressions that are no longer valid in SET because
-   they are clobbered in BLOCK.  */
+   they are clobbered in BLOCK or because they trap and may not be executed.  */
 
 static void
 prune_clobbered_mems (bitmap_set_t set, basic_block block)
 {
-  VEC (pre_expr, heap) *exprs = sorted_array_from_bitmap_set (set);
-  pre_expr expr;
-  int i;
+  bitmap_iterator bi;
+  unsigned i;
 
-  FOR_EACH_VEC_ELT (pre_expr, exprs, i, expr)
+  FOR_EACH_EXPR_ID_IN_SET (set, i, bi)
     {
-      vn_reference_t ref;
-      if (expr->kind != REFERENCE)
-       continue;
-
-      ref = PRE_EXPR_REFERENCE (expr);
-      if (ref->vuse)
+      pre_expr expr = expression_for_id (i);
+      if (expr->kind == REFERENCE)
+       {
+         vn_reference_t ref = PRE_EXPR_REFERENCE (expr);
+         if (ref->vuse)
+           {
+             gimple def_stmt = SSA_NAME_DEF_STMT (ref->vuse);
+             if (!gimple_nop_p (def_stmt)
+                 && ((gimple_bb (def_stmt) != block
+                      && !dominated_by_p (CDI_DOMINATORS,
+                                          block, gimple_bb (def_stmt)))
+                     || (gimple_bb (def_stmt) == block
+                         && value_dies_in_block_x (expr, block))))
+               bitmap_remove_from_set (set, expr);
+           }
+       }
+      else if (expr->kind == NARY)
        {
-         gimple def_stmt = SSA_NAME_DEF_STMT (ref->vuse);
-         if (!gimple_nop_p (def_stmt)
-             && ((gimple_bb (def_stmt) != block
-                  && !dominated_by_p (CDI_DOMINATORS,
-                                      block, gimple_bb (def_stmt)))
-                 || (gimple_bb (def_stmt) == block
-                     && value_dies_in_block_x (expr, block))))
+         vn_nary_op_t nary = PRE_EXPR_NARY (expr);
+         /* If the NARY may trap make sure the block does not contain
+            a possible exit point.
+            ???  This is overly conservative if we translate AVAIL_OUT
+            as the available expression might be after the exit point.  */
+         if (BB_MAY_NOTRETURN (block)
+             && vn_nary_may_trap (nary))
            bitmap_remove_from_set (set, expr);
        }
     }
-  VEC_free (pre_expr, heap, exprs);
 }
 
 static sbitmap has_abnormal_preds;
@@ -4119,6 +4121,13 @@ compute_avail (void)
                        if (TREE_CODE (nary->op[i]) == SSA_NAME)
                          add_to_exp_gen (block, nary->op[i]);
 
+                     /* If the NARY traps and there was a preceeding
+                        point in the block that might not return avoid
+                        adding the nary to EXP_GEN.  */
+                     if (BB_MAY_NOTRETURN (block)
+                         && vn_nary_may_trap (nary))
+                       continue;
+
                      result = (pre_expr) pool_alloc (pre_expr_pool);
                      result->kind = NARY;
                      result->id = 0;