]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fix codegen error exposed by compute isl flow patch
authorAditya Kumar <aditya.k7@samsung.com>
Thu, 21 Jan 2016 02:14:12 +0000 (02:14 +0000)
committerSebastian Pop <spop@gcc.gnu.org>
Thu, 21 Jan 2016 02:14:12 +0000 (02:14 +0000)
we used to fail using an iv from a different loop.

* graphite-isl-ast-to-gimple.c (enum phi_node_kind): New.
(class translate_isl_ast_to_gimple): Use phi_node_kind instead of bool.
(is_valid_rename): Same.
(translate_isl_ast_to_gimple::get_rename): Same.
(translate_isl_ast_to_gimple::rename_all_uses): Same.
(translate_isl_ast_to_gimple::rename_uses): Same.
(get_new_name): Check for close_phi nodes.
(copy_loop_phi_args): Use phi_node_kind.
(translate_isl_ast_to_gimple::copy_loop_close_phi_args): Same.
(translate_isl_ast_to_gimple::copy_cond_phi_args): Same.

gcc/testsuite

* gfortran.dg/graphite/interchange-3.f90: Adjust pattern.

Co-Authored-By: Sebastian Pop <s.pop@samsung.com>
From-SVN: r232660

gcc/ChangeLog
gcc/graphite-isl-ast-to-gimple.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/graphite/interchange-3.f90

index f906edeb514563f167c7cb14e636031104532312..f29a9f114152647b3089a13f68899eb85488b704 100644 (file)
@@ -1,3 +1,17 @@
+2016-01-21  Aditya Kumar  <aditya.k7@samsung.com>
+           Sebastian Pop  <s.pop@samsung.com>
+
+       * graphite-isl-ast-to-gimple.c (enum phi_node_kind): New.
+       (class translate_isl_ast_to_gimple): Use phi_node_kind instead of bool.
+       (is_valid_rename): Same.
+       (translate_isl_ast_to_gimple::get_rename): Same.
+       (translate_isl_ast_to_gimple::rename_all_uses): Same.
+       (translate_isl_ast_to_gimple::rename_uses): Same.
+       (get_new_name): Check for close_phi nodes.
+       (copy_loop_phi_args): Use phi_node_kind.
+       (translate_isl_ast_to_gimple::copy_loop_close_phi_args): Same.
+       (translate_isl_ast_to_gimple::copy_cond_phi_args): Same.
+
 2016-01-21  Aditya Kumar  <aditya.k7@samsung.com>
            Sebastian Pop  <s.pop@samsung.com>
 
index 98e347ae9190dbacc75c44e47a2755e84d2283d6..562cee0c8862aec9c8f7a98efac14ee8ae381375 100644 (file)
@@ -138,6 +138,14 @@ set_separate_option (__isl_take isl_schedule_node *node, void *user)
 }
 #endif
 
+enum phi_node_kind
+{
+  unknown_phi,
+  loop_phi,
+  close_phi,
+  cond_phi
+};
+
 class translate_isl_ast_to_gimple
 {
  public:
@@ -328,14 +336,14 @@ class translate_isl_ast_to_gimple
      SSA form.  */
 
   bool is_valid_rename (tree rename, basic_block def_bb, basic_block use_bb,
-                       bool loop_phi, tree old_name, basic_block old_bb) const;
+                       phi_node_kind, tree old_name, basic_block old_bb) const;
 
   /* Returns the expression associated to OLD_NAME (which is used in OLD_BB), in
      NEW_BB from RENAME_MAP.  LOOP_PHI is true when we want to rename OLD_NAME
      within a loop PHI instruction.  */
 
   tree get_rename (basic_block new_bb, tree old_name,
-                  basic_block old_bb, bool loop_phi) const;
+                  basic_block old_bb, phi_node_kind) const;
 
   /* For ops which are scev_analyzeable, we can regenerate a new name from
   its scalar evolution around LOOP.  */
@@ -355,7 +363,7 @@ class translate_isl_ast_to_gimple
      true when we want to rename an OP within a loop PHI instruction.  */
 
   tree get_new_name (basic_block new_bb, tree op,
-                    basic_block old_bb, bool loop_phi) const;
+                    basic_block old_bb, phi_node_kind) const;
 
   /* Collect all the operands of NEW_EXPR by recursively visiting each
      operand.  */
@@ -1373,7 +1381,7 @@ phi_uses_name (basic_block bb, tree name)
 bool
 translate_isl_ast_to_gimple::
 is_valid_rename (tree rename, basic_block def_bb, basic_block use_bb,
-                bool loop_phi, tree old_name, basic_block old_bb) const
+                phi_node_kind phi_kind, tree old_name, basic_block old_bb) const
 {
   /* The def of the rename must either dominate the uses or come from a
      back-edge.  Also the def must respect the loop closed ssa form.  */
@@ -1391,7 +1399,7 @@ is_valid_rename (tree rename, basic_block def_bb, basic_block use_bb,
   if (dominated_by_p (CDI_DOMINATORS, use_bb, def_bb))
     return true;
 
-  if (bb_contains_loop_phi_nodes (use_bb) && loop_phi)
+  if (bb_contains_loop_phi_nodes (use_bb) && phi_kind == loop_phi)
     {
       /* The loop-header dominates the loop-body.  */
       if (!dominated_by_p (CDI_DOMINATORS, def_bb, use_bb))
@@ -1410,14 +1418,13 @@ is_valid_rename (tree rename, basic_block def_bb, basic_block use_bb,
 }
 
 /* Returns the expression associated to OLD_NAME (which is used in OLD_BB), in
-   NEW_BB from RENAME_MAP.  LOOP_PHI is true when we want to rename OLD_NAME
-   within a loop PHI instruction.  */
+   NEW_BB from RENAME_MAP.  PHI_KIND determines the kind of phi node.  */
 
 tree
 translate_isl_ast_to_gimple::get_rename (basic_block new_bb,
                                         tree old_name,
                                         basic_block old_bb,
-                                        bool loop_phi) const
+                                        phi_node_kind phi_kind) const
 {
   gcc_assert (TREE_CODE (old_name) == SSA_NAME);
   vec <tree> *renames = region->rename_map->get (old_name);
@@ -1431,7 +1438,9 @@ translate_isl_ast_to_gimple::get_rename (basic_block new_bb,
       if (TREE_CODE (rename) == SSA_NAME)
        {
          basic_block bb = gimple_bb (SSA_NAME_DEF_STMT (rename));
-         if (is_valid_rename (rename, bb, new_bb, loop_phi, old_name, old_bb))
+         if (is_valid_rename (rename, bb, new_bb, phi_kind, old_name, old_bb)
+             && (phi_kind == close_phi
+                 || flow_bb_inside_loop_p (bb->loop_father, new_bb)))
            return rename;
          return NULL_TREE;
        }
@@ -1459,6 +1468,9 @@ translate_isl_ast_to_gimple::get_rename (basic_block new_bb,
       if (!dominated_by_p (CDI_DOMINATORS, new_bb, t2_bb))
        continue;
 
+      if (!flow_bb_inside_loop_p (t2_bb->loop_father, new_bb))
+       continue;
+
       /* Compute the nearest dominator.  */
       if (!t1 || dominated_by_p (CDI_DOMINATORS, t2_bb, t1_bb))
        {
@@ -1787,7 +1799,7 @@ translate_isl_ast_to_gimple::rename_all_uses (tree new_expr, basic_block new_bb,
   tree t;
   int i;
   FOR_EACH_VEC_ELT (ssa_names, i, t)
-    if (tree r = get_rename (new_bb, t, old_bb, false))
+    if (tree r = get_rename (new_bb, t, old_bb, unknown_phi))
       new_expr = substitute_ssa_name (new_expr, t, r);
 
   return new_expr;
@@ -1918,7 +1930,7 @@ translate_isl_ast_to_gimple::rename_uses (gimple *copy,
 
       changed = true;
       tree new_expr = get_rename (gsi_tgt->bb, old_name,
-                                 old_bb, false);
+                                 old_bb, unknown_phi);
 
       if (new_expr)
        {
@@ -2017,19 +2029,19 @@ translate_isl_ast_to_gimple::get_def_bb_for_const (basic_block bb,
   return b1;
 }
 
-/* Get the new name of OP (from OLD_BB) to be used in NEW_BB.  LOOP_PHI is true
-   when we want to rename an OP within a loop PHI instruction.  */
+/* Get the new name of OP (from OLD_BB) to be used in NEW_BB.  PHI_KIND
+   determines the kind of phi node.  */
 
 tree
 translate_isl_ast_to_gimple::
 get_new_name (basic_block new_bb, tree op,
-             basic_block old_bb, bool loop_phi) const
+             basic_block old_bb, phi_node_kind phi_kind) const
 {
   /* For constants the names are the same.  */
   if (is_constant (op))
     return op;
 
-  return get_rename (new_bb, op, old_bb, loop_phi);
+  return get_rename (new_bb, op, old_bb, phi_kind);
 }
 
 /* Return a debug location for OP.  */
@@ -2084,7 +2096,7 @@ copy_loop_phi_args (gphi *old_phi, init_back_edge_pair_t &ibp_old_bb,
 
       tree old_name = gimple_phi_arg_def (old_phi, i);
       tree new_name = get_new_name (new_bb, old_name,
-                                   gimple_bb (old_phi), true);
+                                   gimple_bb (old_phi), loop_phi);
       if (new_name)
        {
          add_phi_arg (new_phi, new_name, e, get_loc (old_name));
@@ -2346,7 +2358,7 @@ translate_isl_ast_to_gimple::copy_loop_close_phi_args (basic_block old_bb,
       set_rename (res, new_res);
 
       tree old_name = gimple_phi_arg_def (old_close_phi, 0);
-      tree new_name = get_new_name (new_bb, old_name, old_bb, false);
+      tree new_name = get_new_name (new_bb, old_name, old_bb, close_phi);
 
       /* Predecessor basic blocks of a loop close phi should have been code
         generated before.  FIXME: This is fixable by merging PHIs from inner
@@ -2620,7 +2632,7 @@ translate_isl_ast_to_gimple::copy_cond_phi_args (gphi *phi, gphi *new_phi,
   for (unsigned i = 0; i < gimple_phi_num_args (phi); i++)
     {
       tree old_name = gimple_phi_arg_def (phi, i);
-      tree new_name = get_new_name (new_bb, old_name, old_bb, false);
+      tree new_name = get_new_name (new_bb, old_name, old_bb, cond_phi);
       old_phi_args[i] = old_name;
       if (new_name)
        {
index 88774dd93a79481e5dd6e3a8e13a280c6ca75885..50aa4392641f7997e8e18a65d0cd2cac36aae1ab 100644 (file)
@@ -1,3 +1,8 @@
+2016-01-21  Aditya Kumar  <aditya.k7@samsung.com>
+           Sebastian Pop  <s.pop@samsung.com>
+
+       * gfortran.dg/graphite/interchange-3.f90: Adjust pattern.
+
 2016-01-21  Aditya Kumar  <aditya.k7@samsung.com>
            Sebastian Pop  <s.pop@samsung.com>
 
index 8070bbb4a8d5a0860c92585126955100a765f51c..a66ddfd147a1a81c1802a1e4c1968a61d5b4fac4 100644 (file)
@@ -24,4 +24,4 @@ Program FOO
 
 end Program FOO
 
-! { dg-final { scan-tree-dump "tiled" "graphite" } }
+! { dg-final { scan-tree-dump-times "unsuccessful, reverting back to the original code." "1" "graphite" } }