public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH][GRAPHITE] Abstract away codegen_error setting
Date: Fri, 29 Sep 2017 08:52:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.20.1709291051140.6597@zhemvz.fhfr.qr> (raw)


This moves it to a function to make it easy to enable ICEin on them
in one place.

Bootstrapped / tested on x86_64-unknown-linux-gnu, applied.

Richard.

2017-09-29  Richard Biener  <rguenther@suse.de>

	* graphite-isl-ast-to-gimple.c
	(translate_isl_ast_to_gimple::set_codegen_error): New function.
	(binary_op_to_tree): Use it.
	(get_rename_from_scev): Likewise.
	(copy_loop_phi_nodes): Likewise.
	(copy_bb_and_scalar_dependences): Likewise.
	(translate_pending_phi_nodes): Likewise.

Index: gcc/graphite-isl-ast-to-gimple.c
===================================================================
--- gcc/graphite-isl-ast-to-gimple.c	(revision 253249)
+++ gcc/graphite-isl-ast-to-gimple.c	(working copy)
@@ -240,6 +240,7 @@ class translate_isl_ast_to_gimple
   void gsi_insert_earliest (gimple_seq seq);
   tree rename_all_uses (tree new_expr, basic_block new_bb, basic_block old_bb);
   bool codegen_error_p () const { return codegen_error; }
+  void set_codegen_error () { codegen_error = true; }
   bool is_constant (tree op) const
   {
     return TREE_CODE (op) == INTEGER_CST
@@ -347,7 +348,7 @@ binary_op_to_tree (tree type, __isl_take
 	 division by 2^64 that is folded to 0.  */
       if (integer_zerop (tree_rhs_expr))
 	{
-	  codegen_error = true;
+	  set_codegen_error ();
 	  return NULL_TREE;
 	}
       return fold_build2 (EXACT_DIV_EXPR, type, tree_lhs_expr, tree_rhs_expr);
@@ -357,7 +358,7 @@ binary_op_to_tree (tree type, __isl_take
 	 division by 2^64 that is folded to 0.  */
       if (integer_zerop (tree_rhs_expr))
 	{
-	  codegen_error = true;
+	  set_codegen_error ();
 	  return NULL_TREE;
 	}
       return fold_build2 (TRUNC_DIV_EXPR, type, tree_lhs_expr, tree_rhs_expr);
@@ -368,7 +369,7 @@ binary_op_to_tree (tree type, __isl_take
 	 division by 2^64 that is folded to 0.  */
       if (integer_zerop (tree_rhs_expr))
 	{
-	  codegen_error = true;
+	  set_codegen_error ();
 	  return NULL_TREE;
 	}
       return fold_build2 (TRUNC_MOD_EXPR, type, tree_lhs_expr, tree_rhs_expr);
@@ -378,7 +379,7 @@ binary_op_to_tree (tree type, __isl_take
 	 division by 2^64 that is folded to 0.  */
       if (integer_zerop (tree_rhs_expr))
 	{
-	  codegen_error = true;
+	  set_codegen_error ();
 	  return NULL_TREE;
 	}
       return fold_build2 (FLOOR_DIV_EXPR, type, tree_lhs_expr, tree_rhs_expr);
@@ -1497,7 +1498,7 @@ get_rename_from_scev (tree old_name, gim
   tree new_expr;
   if (chrec_contains_undetermined (scev))
     {
-      codegen_error = true;
+      set_codegen_error ();
       return build_zero_cst (TREE_TYPE (old_name));
     }
 
@@ -1510,7 +1511,7 @@ get_rename_from_scev (tree old_name, gim
   if (chrec_contains_undetermined (new_expr)
       || tree_contains_chrecs (new_expr, NULL))
     {
-      codegen_error = true;
+      set_codegen_error ();
       return build_zero_cst (TREE_TYPE (old_name));
     }
 
@@ -1519,7 +1520,7 @@ get_rename_from_scev (tree old_name, gim
       basic_block bb = gimple_bb (SSA_NAME_DEF_STMT (new_expr));
       if (bb && !dominated_by_p (CDI_DOMINATORS, new_bb, bb))
 	{
-	  codegen_error = true;
+	  set_codegen_error ();
 	  return build_zero_cst (TREE_TYPE (old_name));
 	}
     }
@@ -1539,7 +1540,7 @@ get_rename_from_scev (tree old_name, gim
 	  basic_block bb = gimple_bb (SSA_NAME_DEF_STMT (new_ssa_name));
 	  if (bb && !dominated_by_p (CDI_DOMINATORS, new_bb, bb))
 	    {
-	      codegen_error = true;
+	      set_codegen_error ();
 	      return build_zero_cst (TREE_TYPE (old_name));
 	    }
 	}
@@ -1820,8 +1822,8 @@ copy_loop_phi_nodes (basic_block bb, bas
       tree new_res = create_new_def_for (res, new_phi,
 					 gimple_phi_result_ptr (new_phi));
       set_rename (res, new_res);
-      codegen_error = !copy_loop_phi_args (phi, ibp_old_bb, new_phi,
-					   ibp_new_bb, true);
+      if (!copy_loop_phi_args (phi, ibp_old_bb, new_phi, ibp_new_bb, true))
+	set_codegen_error ();
       update_stmt (new_phi);
 
       if (dump_file)
@@ -2593,7 +2595,7 @@ copy_bb_and_scalar_dependences (basic_bl
 	 outside the region.  */
       if (num_phis)
 	{
-	  codegen_error = true;
+	  set_codegen_error ();
 	  return NULL;
 	}
     }
@@ -2608,7 +2610,7 @@ copy_bb_and_scalar_dependences (basic_bl
       edge e = edge_for_new_close_phis (bb);
       if (!e)
 	{
-	  codegen_error = true;
+	  set_codegen_error ();
 	  return NULL;
 	}
 
@@ -2622,7 +2624,7 @@ copy_bb_and_scalar_dependences (basic_bl
 
       if (!copy_loop_close_phi_nodes (bb, phi_bb, iv_map))
 	{
-	  codegen_error = true;
+	  set_codegen_error ();
 	  return NULL;
 	}
 
@@ -2644,7 +2646,7 @@ copy_bb_and_scalar_dependences (basic_bl
 	     code.  See gfortran.dg/graphite/pr29832.f90.  */
 	  if (EDGE_COUNT (bb->preds) != EDGE_COUNT (phi_bb->preds))
 	    {
-	      codegen_error = true;
+	      set_codegen_error ();
 	      return NULL;
 	    }
 
@@ -2664,7 +2666,7 @@ copy_bb_and_scalar_dependences (basic_bl
 	     extend that to reductions that cannot be analyzed by SCEV.  */
 	  if (!bb_in_sese_p (phi_bb, region->if_region->true_region->region))
 	    {
-	      codegen_error = true;
+	      set_codegen_error ();
 	      return NULL;
 	    }
 
@@ -2673,7 +2675,7 @@ copy_bb_and_scalar_dependences (basic_bl
 		     bb->index);
 	  if (!copy_loop_phi_nodes (bb, phi_bb))
 	    {
-	      codegen_error = true;
+	      set_codegen_error ();
 	      return NULL;
 	    }
 	}
@@ -2695,7 +2697,7 @@ copy_bb_and_scalar_dependences (basic_bl
 	      || !bb_in_sese_p (phi_bb, region->if_region->true_region->region)
 	      || !copy_cond_phi_nodes (bb, phi_bb, iv_map))
 	    {
-	      codegen_error = true;
+	      set_codegen_error ();
 	      return NULL;
 	    }
 	}
@@ -2718,7 +2720,7 @@ copy_bb_and_scalar_dependences (basic_bl
 
   if (!graphite_copy_stmts_from_block (bb, new_bb, iv_map))
     {
-      codegen_error = true;
+      set_codegen_error ();
       return NULL;
     }
 
@@ -2752,12 +2754,18 @@ translate_pending_phi_nodes ()
       auto_vec <tree, 1> iv_map;
       if (bb_contains_loop_phi_nodes (new_bb)
 	  && bb_contains_loop_phi_nodes (old_bb))
-	codegen_error = !copy_loop_phi_args (old_phi, ibp_old_bb, new_phi,
-					    ibp_new_bb, false);
+	{
+	  if (!copy_loop_phi_args (old_phi, ibp_old_bb, new_phi,
+				   ibp_new_bb, false))
+	    set_codegen_error ();
+	}
       else if (bb_contains_loop_close_phi_nodes (new_bb))
-	codegen_error = !copy_loop_close_phi_args (old_bb, new_bb, iv_map, false);
-      else
-	codegen_error = !copy_cond_phi_args (old_phi, new_phi, iv_map, false);
+	{
+	  if (!copy_loop_close_phi_args (old_bb, new_bb, iv_map, false))
+	    set_codegen_error ();
+	}
+      else if (!copy_cond_phi_args (old_phi, new_phi, iv_map, false))
+	set_codegen_error ();
 
       if (dump_file)
 	{

             reply	other threads:[~2017-09-29  8:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-29  8:52 Richard Biener [this message]
2017-09-29 14:32 ` Sebastian Pop

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.20.1709291051140.6597@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).