re PR tree-optimization/71351 (ICE: Segmentation fault (graphite))
authorRichard Biener <rguenther@suse.de>
Thu, 21 Sep 2017 10:08:21 +0000 (10:08 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 21 Sep 2017 10:08:21 +0000 (10:08 +0000)
2017-09-21  Richard Biener  <rguenther@suse.de>

PR tree-optimization/71351
* graphite-isl-ast-to-gimple.c (translate_isl_ast_to_gimple::
graphite_create_new_loop_guard): Remove, fold remaining parts
into caller ...
(translate_isl_ast_node_for): ... here and simplify.

* gfortran.dg/graphite/pr71351.f90: New testcase.
* gfortran.dg/graphite/interchange-3.f90: Adjust.

From-SVN: r253052

gcc/ChangeLog
gcc/graphite-isl-ast-to-gimple.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/graphite/interchange-3.f90
gcc/testsuite/gfortran.dg/graphite/pr71351.f90 [new file with mode: 0644]

index 849178575d3d840b6ef5a407d07c49040926d62f..80803d622948bd98e60aaff51e8d00b4b90d4781 100644 (file)
@@ -1,3 +1,11 @@
+2017-09-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71351
+       * graphite-isl-ast-to-gimple.c (translate_isl_ast_to_gimple::
+       graphite_create_new_loop_guard): Remove, fold remaining parts
+       into caller ...
+       (translate_isl_ast_node_for): ... here and simplify.
+
 2017-09-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/82260
index 964d6c9755399a7f452e10f9d2be3f43a26127bf..ccf0c21286c9a3593275ecfa416038a0db06287e 100644 (file)
@@ -193,10 +193,6 @@ class translate_isl_ast_to_gimple
                                         __isl_keep isl_ast_node *node_for,
                                         loop_p outer, tree type,
                                         tree lb, tree ub, ivs_params &ip);
-  edge graphite_create_new_loop_guard (edge entry_edge,
-                                      __isl_keep isl_ast_node *node_for,
-                                      tree *type,
-                                      tree *lb, tree *ub, ivs_params &ip);
   edge graphite_create_new_guard (edge entry_edge,
                                  __isl_take isl_ast_expr *if_cond,
                                  ivs_params &ip);
@@ -731,71 +727,6 @@ get_upper_bound (__isl_keep isl_ast_node *node_for)
   return res;
 }
 
-/* All loops generated by create_empty_loop_on_edge have the form of
-   a post-test loop:
-
-   do
-
-   {
-     body of the loop;
-   } while (lower bound < upper bound);
-
-   We create a new if region protecting the loop to be executed, if
-   the execution count is zero (lower bound > upper bound).  */
-
-edge translate_isl_ast_to_gimple::
-graphite_create_new_loop_guard (edge entry_edge,
-                               __isl_keep isl_ast_node *node_for, tree *type,
-                               tree *lb, tree *ub, ivs_params &ip)
-{
-  gcc_assert (isl_ast_node_get_type (node_for) == isl_ast_node_for);
-  tree cond_expr;
-  edge exit_edge;
-
-  *type =
-    build_nonstandard_integer_type (graphite_expression_type_precision, 0);
-  isl_ast_expr *for_init = isl_ast_node_for_get_init (node_for);
-  *lb = gcc_expression_from_isl_expression (*type, for_init, ip);
-
-  /* To fail code generation, we generate wrong code until we discard it.  */
-  if (codegen_error_p ())
-    *lb = integer_zero_node;
-
-  isl_ast_expr *upper_bound = get_upper_bound (node_for);
-  *ub = gcc_expression_from_isl_expression (*type, upper_bound, ip);
-
-  /* To fail code generation, we generate wrong code until we discard it.  */
-  if (codegen_error_p ())
-    *ub = integer_zero_node;
-  
-  /* When ub is simply a constant or a parameter, use lb <= ub.  */
-  if (TREE_CODE (*ub) == INTEGER_CST || TREE_CODE (*ub) == SSA_NAME)
-    cond_expr = fold_build2 (LE_EXPR, boolean_type_node, *lb, *ub);
-  else
-    {
-      tree one = (POINTER_TYPE_P (*type)
-                 ? convert_to_ptrofftype (integer_one_node)
-                 : fold_convert (*type, integer_one_node));
-      /* Adding +1 and using LT_EXPR helps with loop latches that have a
-        loop iteration count of "PARAMETER - 1".  For PARAMETER == 0 this
-        becomes 2^k-1 due to integer overflow, and the condition lb <= ub
-        is true, even if we do not want this.  However lb < ub + 1 is false,
-        as expected.  */
-      tree ub_one = fold_build2 (POINTER_TYPE_P (*type) ? POINTER_PLUS_EXPR
-                                : PLUS_EXPR, *type, *ub, one);
-
-      cond_expr = fold_build2 (LT_EXPR, boolean_type_node, *lb, ub_one);
-    }
-
-  if (integer_onep (cond_expr))
-    exit_edge = entry_edge;
-  else
-    exit_edge = create_empty_if_region_on_edge (entry_edge,
-                                               unshare_expr (cond_expr));
-
-  return exit_edge;
-}
-
 /* Translates an isl_ast_node_for to Gimple. */
 
 edge translate_isl_ast_to_gimple::
@@ -803,26 +734,24 @@ translate_isl_ast_node_for (loop_p context_loop, __isl_keep isl_ast_node *node,
                            edge next_e, ivs_params &ip)
 {
   gcc_assert (isl_ast_node_get_type (node) == isl_ast_node_for);
-  tree type, lb, ub;
-  edge last_e = graphite_create_new_loop_guard (next_e, node, &type,
-                                               &lb, &ub, ip);
-
-  if (last_e == next_e)
-    {
-      /* There was no guard generated.  */
-      last_e = single_succ_edge (split_edge (last_e));
-
-      translate_isl_ast_for_loop (context_loop, node, next_e,
-                                 type, lb, ub, ip);
-      return last_e;
-    }
+  tree type
+    = build_nonstandard_integer_type (graphite_expression_type_precision, 0);
 
-  edge true_e = get_true_edge_from_guard_bb (next_e->dest);
-  merge_points.safe_push (last_e);
+  isl_ast_expr *for_init = isl_ast_node_for_get_init (node);
+  tree lb = gcc_expression_from_isl_expression (type, for_init, ip);
+  /* To fail code generation, we generate wrong code until we discard it.  */
+  if (codegen_error_p ())
+    lb = integer_zero_node;
 
-  last_e = single_succ_edge (split_edge (last_e));
-  translate_isl_ast_for_loop (context_loop, node, true_e, type, lb, ub, ip);
+  isl_ast_expr *upper_bound = get_upper_bound (node);
+  tree ub = gcc_expression_from_isl_expression (type, upper_bound, ip);
+  /* To fail code generation, we generate wrong code until we discard it.  */
+  if (codegen_error_p ())
+    ub = integer_zero_node;
 
+  edge last_e = single_succ_edge (split_edge (next_e));
+  translate_isl_ast_for_loop (context_loop, node, next_e,
+                             type, lb, ub, ip);
   return last_e;
 }
 
index 4193c3ba6d438f92c19dfd1d863288ec80ffc8cf..870d2543179414df26b0634b431f51d283568b61 100644 (file)
@@ -1,3 +1,9 @@
+2017-09-21  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/71351
+       * gfortran.dg/graphite/pr71351.f90: New testcase.
+       * gfortran.dg/graphite/interchange-3.f90: Adjust.
+
 2017-09-21  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/82260
index f20eaa971cf333228f1e6c2fd33e7464f8d7a785..8070bbb4a8d5a0860c92585126955100a765f51c 100644 (file)
@@ -24,4 +24,4 @@ Program FOO
 
 end Program FOO
 
-! { dg-final { scan-tree-dump-times "codegen error: reverting back to the original code." "1" "graphite" } }
+! { dg-final { scan-tree-dump "tiled" "graphite" } }
diff --git a/gcc/testsuite/gfortran.dg/graphite/pr71351.f90 b/gcc/testsuite/gfortran.dg/graphite/pr71351.f90
new file mode 100644 (file)
index 0000000..8251930
--- /dev/null
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! { dg-options "-O2 -floop-nest-optimize" }
+
+SUBROUTINE print_crys_symmetry(nc,v)
+  INTEGER :: nc
+  REAL(KIND=8), DIMENSION(3,48) :: v
+  INTEGER  :: n,i
+  vs = 0.0_8
+  DO n = 1, nc 
+     DO i = 1, 3
+        vs = vs + ABS(v(i,n))
+     END DO
+  END DO
+  CALL foo(vs)
+END SUBROUTINE print_crys_symmetry