diff gcc/graphite-isl-ast-to-gimple.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
line wrap: on
line diff
--- a/gcc/graphite-isl-ast-to-gimple.c	Fri Oct 27 22:46:09 2017 +0900
+++ b/gcc/graphite-isl-ast-to-gimple.c	Thu Oct 25 07:37:49 2018 +0900
@@ -1,5 +1,5 @@
 /* Translation of isl AST to Gimple.
-   Copyright (C) 2014-2017 Free Software Foundation, Inc.
+   Copyright (C) 2014-2018 Free Software Foundation, Inc.
    Contributed by Roman Gareev <gareevroman@gmail.com>.
 
 This file is part of GCC.
@@ -326,7 +326,9 @@
   /* 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)))
@@ -720,6 +722,32 @@
     ub = integer_zero_node;
 
   edge last_e = single_succ_edge (split_edge (next_e));
+
+  /* Compensate for the fact that we emit a do { } while loop from
+     a for ISL AST.
+     ???  We often miss constraints on niter because the SESE region
+     doesn't cover loop header copies.  Ideally we'd add constraints
+     for all relevant dominating conditions.  */
+  if (TREE_CODE (lb) == INTEGER_CST && TREE_CODE (ub) == INTEGER_CST
+      && tree_int_cst_compare (lb, ub) <= 0)
+    ;
+  else
+    {
+      tree one = build_one_cst (POINTER_TYPE_P (type) ? sizetype : type);
+      /* 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, unshare_expr (ub), one);
+      create_empty_if_region_on_edge (next_e,
+				      fold_build2 (LT_EXPR, boolean_type_node,
+						   unshare_expr (lb), ub_one));
+      next_e = get_true_edge_from_guard_bb (next_e->dest);
+    }
+
   translate_isl_ast_for_loop (context_loop, node, next_e,
 			      type, lb, ub, ip);
   return last_e;
@@ -1007,7 +1035,7 @@
   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;
@@ -1039,7 +1067,7 @@
       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);
 	}
@@ -1111,8 +1139,10 @@
   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;
@@ -1146,7 +1176,8 @@
 	{
 	  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 ();
@@ -1378,7 +1409,7 @@
   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
+      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,
@@ -1487,7 +1518,7 @@
 
   if (t.codegen_error_p ())
     {
-      location_t loc = find_loop_location
+      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");