This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] fix SPEC ICE - violating loop-closed-form in the vectorizer





The recent patch to incrementally preserve loop-closed-form when
transforming a loop in the vectorizer, neglected another place in the
vectorizer where a minor transformation takes place and loop-closed-form
needs to be fixed. This actually happens during the analysis stage, when we
split the exit-edge of a loop if the exit-block doesn't have a single
predecessor. I forgot about this bit. This patch fixes this by adding the
required loop-closed phis at the newly created exit-bb.

Bootstrapped with vectorization enabled on powerpc-apple-darwin, tested on
the vectorizer testcases and SPEC.

ok for mainline?

thanks,
dorit

Changelog:

      * tree-flow.h (loop_closed_split_exit_edge): New function
      declaration.
      * tree-ssa-loop-manip.c (loop_closed_split_exit_edge):
      New function.
      * tree-vect-analyze.c (vect_analyze_loop_form): Call
      loop_closed_split_exit_edge instead of loop_split_edge_with.

Patch:

Index: tree-flow.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-flow.h,v
retrieving revision 2.88
diff -c -3 -p -r2.88 tree-flow.h
*** tree-flow.h   29 Mar 2005 11:45:49 -0000    2.88
--- tree-flow.h   31 Mar 2005 16:17:14 -0000
*************** tree can_count_iv_in_wider_type (struct
*** 709,714 ****
--- 709,715 ----
  void free_numbers_of_iterations_estimates (struct loops *);
  void rewrite_into_loop_closed_ssa (bitmap);
  void verify_loop_closed_ssa (void);
+ basic_block loop_closed_split_exit_edge (edge);
  void loop_commit_inserts (void);
  bool for_each_index (tree *, bool (*) (tree, tree *, void *), void *);
  void create_iv (tree, tree, tree, struct loop *, block_stmt_iterator *, bool,
Index: tree-ssa-loop-manip.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-loop-manip.c,v
retrieving revision 2.26
diff -c -3 -p -r2.26 tree-ssa-loop-manip.c
*** tree-ssa-loop-manip.c     11 Mar 2005 09:05:10 -0000    2.26
--- tree-ssa-loop-manip.c     31 Mar 2005 16:17:14 -0000
*************** check_loop_closed_ssa_use (basic_block b
*** 391,396 ****
--- 391,440 ----
            || flow_bb_inside_loop_p (def_bb->loop_father, bb));
  }

+
+ /*
+    Split the exit-edge of a loop, preserving loop-closed-form.
+    Similar to loop_split_edge_with(e,NULL), with the restriction that the edge
+    is a loop-exit edge and the loop is in loop closed form.
+
+    EXIT_EDGE is a loop-exit edge.  The loop is in loop-closed form, which means
+    that in EXIT_EDGE->dest (denoted ORIG_EXIT_BB) we have the necessary
+    loop-closed phis.
+    This function splits the edge EXIT_EDGE, and if a new basic-block is
+    created as a result (NEW_EXIT_BB), it inserts the necessary loop-closed phis
+    in NEW_EXIT_BB, and updates accordingly the phis in ORIG_EXIT_BB.
+ */
+
+ basic_block
+ loop_closed_split_exit_edge (edge exit_edge)
+ {
+   basic_block orig_exit_bb = exit_edge->dest;
+   basic_block new_exit_bb;
+   edge new_exit_e;
+   tree orig_phi, new_phi;
+   tree arg;
+
+   new_exit_bb = loop_split_edge_with (exit_edge, NULL);
+
+   if (!new_exit_bb)
+     return NULL;
+
+   new_exit_e = EDGE_SUCC (new_exit_bb, 0);
+
+   for (orig_phi = phi_nodes (orig_exit_bb); orig_phi;
+        orig_phi = PHI_CHAIN (orig_phi))
+     {
+       arg = PHI_ARG_DEF_FROM_EDGE (orig_phi, new_exit_e);
+       new_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (orig_phi)),
+                                  new_exit_bb);
+       add_phi_arg (new_phi, arg, exit_edge);
+       SET_PHI_ARG_DEF (orig_phi, new_exit_e->dest_idx, PHI_RESULT (new_phi));
+     }
+
+   return new_exit_bb;
+ }
+
+
  /* Checks invariants of loop closed ssa form in statement STMT in BB.  */

  static void
Index: tree-vect-analyze.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-vect-analyze.c,v
retrieving revision 2.15
diff -c -3 -p -r2.15 tree-vect-analyze.c
*** tree-vect-analyze.c 29 Mar 2005 16:09:58 -0000    2.15
--- tree-vect-analyze.c 31 Mar 2005 16:17:14 -0000
*************** vect_analyze_loop_form (struct loop *loo
*** 2436,2442 ****
        edge e = loop->single_exit;
        if (!(e->flags & EDGE_ABNORMAL))
      {
!       loop_split_edge_with (e, NULL);
        if (vect_print_dump_info (REPORT_DETAILS, loop_loc))
          fprintf (vect_dump, "split exit edge.");
      }
--- 2436,2442 ----
        edge e = loop->single_exit;
        if (!(e->flags & EDGE_ABNORMAL))
      {
!       loop_closed_split_exit_edge (e);
        if (vect_print_dump_info (REPORT_DETAILS, loop_loc))
          fprintf (vect_dump, "split exit edge.");
      }



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]