Fortran] Use proper type for hidden is-present argument
[gcc.git] / gcc / graphite-isl-ast-to-gimple.c
index c565cf003794b61b82ccc3e22d869d316321bafc..9fe82ecbdb8cdd960a8e38af35d91047034a3d36 100644 (file)
@@ -1,5 +1,5 @@
 /* Translation of isl AST to Gimple.
-   Copyright (C) 2014-2017 Free Software Foundation, Inc.
+   Copyright (C) 2014-2019 Free Software Foundation, Inc.
    Contributed by Roman Gareev <gareevroman@gmail.com>.
 
 This file is part of GCC.
@@ -32,7 +32,6 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree.h"
 #include "gimple.h"
 #include "ssa.h"
-#include "params.h"
 #include "fold-const.h"
 #include "gimple-fold.h"
 #include "gimple-iterator.h"
@@ -203,7 +202,7 @@ class translate_isl_ast_to_gimple
   {
     codegen_error = true;
     gcc_assert (! flag_checking
-               || PARAM_VALUE (PARAM_GRAPHITE_ALLOW_CODEGEN_ERRORS));
+               || param_graphite_allow_codegen_errors);
   }
 
   bool is_constant (tree op) const
@@ -326,7 +325,9 @@ binary_op_to_tree (tree type, __isl_take isl_ast_expr *expr, ivs_params &ip)
   /* From our constraint generation we may get modulo operations that
      we cannot represent explicitely but that are no-ops for TYPE.
      Elide those.  */
-  if (expr_type == isl_ast_op_pdiv_r
+  if ((expr_type == isl_ast_op_pdiv_r
+       || expr_type == isl_ast_op_zdiv_r
+       || expr_type == isl_ast_op_add)
       && isl_ast_expr_get_type (arg_expr) == isl_ast_expr_int
       && (wi::exact_log2 (widest_int_from_isl_expr_int (arg_expr))
          >= TYPE_PRECISION (type)))
@@ -409,7 +410,9 @@ ternary_op_to_tree (tree type, __isl_take isl_ast_expr *expr, ivs_params &ip)
   if (codegen_error_p ())
     return NULL_TREE;
 
-  return fold_build3 (COND_EXPR, type, a, b, c);
+  return fold_build3 (COND_EXPR, type, a,
+                     rewrite_to_non_trapping_overflow (b),
+                     rewrite_to_non_trapping_overflow (c));
 }
 
 /* Converts a unary isl_ast_expr_op expression E to a GCC expression tree of
@@ -739,10 +742,10 @@ translate_isl_ast_node_for (loop_p context_loop, __isl_keep isl_ast_node *node,
         as expected.  */
       tree ub_one = fold_build2 (POINTER_TYPE_P (type)
                                 ? POINTER_PLUS_EXPR : PLUS_EXPR,
-                                type, ub, one);
+                                type, unshare_expr (ub), one);
       create_empty_if_region_on_edge (next_e,
                                      fold_build2 (LT_EXPR, boolean_type_node,
-                                                  lb, ub_one));
+                                                  unshare_expr (lb), ub_one));
       next_e = get_true_edge_from_guard_bb (next_e->dest);
     }
 
@@ -1033,7 +1036,7 @@ gsi_insert_earliest (gimple_seq seq)
   FOR_EACH_VEC_ELT (stmts, i, use_stmt)
     {
       gcc_assert (gimple_code (use_stmt) != GIMPLE_PHI);
-      gimple_stmt_iterator gsi_def_stmt = gsi_start_bb_nondebug (begin_bb);
+      gimple_stmt_iterator gsi_def_stmt = gsi_start_nondebug_bb (begin_bb);
 
       use_operand_p use_p;
       ssa_op_iter op_iter;
@@ -1065,7 +1068,7 @@ gsi_insert_earliest (gimple_seq seq)
       else if (gimple_code (gsi_stmt (gsi_def_stmt)) == GIMPLE_PHI)
        {
          gimple_stmt_iterator bsi
-           = gsi_start_bb_nondebug (gsi_bb (gsi_def_stmt));
+           = gsi_start_nondebug_bb (gsi_bb (gsi_def_stmt));
          /* Insert right after the PHI statements.  */
          gsi_insert_before (&bsi, use_stmt, GSI_NEW_STMT);
        }
@@ -1088,7 +1091,8 @@ tree translate_isl_ast_to_gimple::
 get_rename_from_scev (tree old_name, gimple_seq *stmts, loop_p loop,
                      vec<tree> iv_map)
 {
-  tree scev = scalar_evolution_in_region (region->region, loop, old_name);
+  tree scev = cached_scalar_evolution_in_region (region->region,
+                                                loop, old_name);
 
   /* At this point we should know the exact scev for each
      scalar SSA_NAME used in the scop: all the other scalar
@@ -1137,8 +1141,10 @@ should_copy_to_new_region (gimple *stmt, sese_info_p region)
   if (is_gimple_assign (stmt)
       && (lhs = gimple_assign_lhs (stmt))
       && TREE_CODE (lhs) == SSA_NAME
-      && is_gimple_reg (lhs)
-      && scev_analyzable_p (lhs, region->region))
+      && scev_analyzable_p (lhs, region->region)
+      /* But to code-generate liveouts - liveout PHI generation is
+         in generic sese.c code that cannot do code generation.  */
+      && ! bitmap_bit_p (region->liveout, SSA_NAME_VERSION (lhs)))
     return false;
 
   return true;
@@ -1172,7 +1178,8 @@ graphite_copy_stmts_from_block (basic_block bb, basic_block new_bb,
        {
          if (gimple_debug_bind_p (copy))
            gimple_debug_bind_reset_value (copy);
-         else if (gimple_debug_source_bind_p (copy))
+         else if (gimple_debug_source_bind_p (copy)
+                  || gimple_debug_nonbind_marker_p (copy))
            ;
          else
            gcc_unreachable ();
@@ -1375,7 +1382,7 @@ scop_to_isl_ast (scop_p scop)
 {
   int old_err = isl_options_get_on_error (scop->isl_context);
   int old_max_operations = isl_ctx_get_max_operations (scop->isl_context);
-  int max_operations = PARAM_VALUE (PARAM_MAX_ISL_OPERATIONS);
+  int max_operations = param_max_isl_operations;
   if (max_operations)
     isl_ctx_set_max_operations (scop->isl_context, max_operations);
   isl_options_set_on_error (scop->isl_context, ISL_ON_ERROR_CONTINUE);
@@ -1404,17 +1411,20 @@ scop_to_isl_ast (scop_p scop)
   isl_ctx_set_max_operations (scop->isl_context, old_max_operations);
   if (isl_ctx_last_error (scop->isl_context) != isl_error_none)
     {
-      location_t loc = find_loop_location
-       (scop->scop_info->region.entry->dest->loop_father);
-      if (isl_ctx_last_error (scop->isl_context) == isl_error_quota)
-       dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
-                        "loop nest not optimized, AST generation timed out "
-                        "after %d operations [--param max-isl-operations]\n",
-                        max_operations);
-      else
-       dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
-                        "loop nest not optimized, ISL AST generation "
-                        "signalled an error\n");
+      if (dump_enabled_p ())
+       {
+         dump_user_location_t loc = find_loop_location
+           (scop->scop_info->region.entry->dest->loop_father);
+         if (isl_ctx_last_error (scop->isl_context) == isl_error_quota)
+           dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
+                            "loop nest not optimized, AST generation timed out "
+                            "after %d operations [--param max-isl-operations]\n",
+                            max_operations);
+         else
+           dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
+                            "loop nest not optimized, ISL AST generation "
+                            "signalled an error\n");
+       }
       isl_ast_node_free (ast_isl);
       return NULL;
     }
@@ -1513,10 +1523,13 @@ graphite_regenerate_ast_isl (scop_p scop)
 
   if (t.codegen_error_p ())
     {
-      location_t loc = find_loop_location
-       (scop->scop_info->region.entry->dest->loop_father);
-      dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
-                      "loop nest not optimized, code generation error\n");
+      if (dump_enabled_p ())
+       {
+         dump_user_location_t loc = find_loop_location
+           (scop->scop_info->region.entry->dest->loop_father);
+         dump_printf_loc (MSG_MISSED_OPTIMIZATION, loc,
+                          "loop nest not optimized, code generation error\n");
+       }
 
       /* Remove the unreachable region.  */
       remove_edge_and_dominated_blocks (if_region->true_region->region.entry);