diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fcc7fba7011..b83091ce179 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2005-08-18 Dorit Nuzman + + PR tree-optimization/22228 + * tree-ssa-loop (pass_vectorize): Add TODO_verify_loops to todo_flags_start. + * tree-vect-transform.c (vect_transform_loop): Mark the variables that + are recorded in vect_vnames_to_rename for renaming. + * tree-vectorizer.c (vect_vnames_to_rename): New global bitmap. + (slpeel_update_phi_nodes_for_guard1): Record virtual vars for renaming + in vect_vnames_to_rename. + (vectorize_loops): Allocate and free the vect_vnames_to_rename bitmap. + * tree-vectorizer.h (vect_vnames_to_rename): New extern variable. + 2005-08-18 Jan Hubicka PR c++/22034 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e631fefb03a..1f0c092abb5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-08-18 Dorit Nuzman + + PR tree-optimization/22228 + * g++.dg/vect/pr22543.cc: New test. + 2005-08-17 Steven Bosscher PR tree-optimization/21574 diff --git a/gcc/testsuite/g++.dg/vect/pr22543.cc b/gcc/testsuite/g++.dg/vect/pr22543.cc new file mode 100644 index 00000000000..f5e55f195ef --- /dev/null +++ b/gcc/testsuite/g++.dg/vect/pr22543.cc @@ -0,0 +1,38 @@ +/* { dg-do compile } */ + +struct A +{ + int i, j; + + A() : i(), j() {} + ~A() {} + + operator int() { return 0; } +}; + +struct B +{ + A foo() const { return A(); } +}; + +struct X { ~X(); }; + +struct C +{ + C(); + + int z[4]; +}; + +C::C() +{ + for (int i=0; i<4; ++i) + z[i]=0; + + X x; + + for (int i=0; i<4; ++i) + int j = B().foo(); +} + +/* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/tree-ssa-loop.c b/gcc/tree-ssa-loop.c index abfcf15bc76..05df8d13b65 100644 --- a/gcc/tree-ssa-loop.c +++ b/gcc/tree-ssa-loop.c @@ -212,7 +212,7 @@ struct tree_opt_pass pass_vectorize = PROP_cfg | PROP_ssa, /* properties_required */ 0, /* properties_provided */ 0, /* properties_destroyed */ - 0, /* todo_flags_start */ + TODO_verify_loops, /* todo_flags_start */ TODO_dump_func | TODO_update_ssa, /* todo_flags_finish */ 0 /* letter */ }; diff --git a/gcc/tree-vect-transform.c b/gcc/tree-vect-transform.c index 1923cbce828..be5b7794364 100644 --- a/gcc/tree-vect-transform.c +++ b/gcc/tree-vect-transform.c @@ -2735,10 +2735,16 @@ vect_transform_loop (loop_vec_info loop_vinfo, int i; tree ratio = NULL; int vectorization_factor = LOOP_VINFO_VECT_FACTOR (loop_vinfo); + bitmap_iterator bi; + unsigned int j; if (vect_print_dump_info (REPORT_DETAILS)) fprintf (vect_dump, "=== vec_transform_loop ==="); + /* CHECKME: we wouldn't need this if we calles update_ssa once + for all loops. */ + bitmap_zero (vect_vnames_to_rename); + /* Peel the loop if there are data refs with unknown alignment. Only one data ref with unknown store is allowed. */ @@ -2824,6 +2830,9 @@ vect_transform_loop (loop_vec_info loop_vinfo, slpeel_make_loop_iterate_ntimes (loop, ratio); + EXECUTE_IF_SET_IN_BITMAP (vect_vnames_to_rename, 0, j, bi) + mark_sym_for_renaming (SSA_NAME_VAR (ssa_name (j))); + /* The memory tags and pointers in vectorized statements need to have their SSA forms updated. FIXME, why can't this be delayed until all the loops have been transformed? */ diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c index 4bdb552fa84..1cce052d276 100644 --- a/gcc/tree-vectorizer.c +++ b/gcc/tree-vectorizer.c @@ -179,6 +179,9 @@ unsigned int vect_loops_num; /* Loop location. */ static LOC vect_loop_location; + +/* Bitmap of virtual variables to be renamed. */ +bitmap vect_vnames_to_rename; /************************************************************************* Simple Loop Peeling Utilities @@ -511,6 +514,7 @@ slpeel_update_phi_nodes_for_guard1 (edge guard_edge, struct loop *loop, basic_block orig_bb = loop->header; edge new_exit_e; tree current_new_name; + tree name; /* Create new bb between loop and new_merge_bb. */ *new_exit_bb = split_edge (loop->single_exit); @@ -522,6 +526,15 @@ slpeel_update_phi_nodes_for_guard1 (edge guard_edge, struct loop *loop, orig_phi && update_phi; orig_phi = PHI_CHAIN (orig_phi), update_phi = PHI_CHAIN (update_phi)) { + /* Virtual phi; Mark it for renaming. We actually want to call + mar_sym_for_renaming, but since all ssa renaming datastructures + are going to be freed before we get to call ssa_upate, we just + record this name for now in a bitmap, and will mark it for + renaming later. */ + name = PHI_RESULT (orig_phi); + if (!is_gimple_reg (SSA_NAME_VAR (name))) + bitmap_set_bit (vect_vnames_to_rename, SSA_NAME_VERSION (name)); + /** 1. Handle new-merge-point phis **/ /* 1.1. Generate new phi node in NEW_MERGE_BB: */ @@ -2010,6 +2023,10 @@ vectorize_loops (struct loops *loops) /* Fix the verbosity level if not defined explicitly by the user. */ vect_set_dump_settings (); + /* Allocate the bitmap that records which virtual variables that + need to be renamed. */ + vect_vnames_to_rename = BITMAP_ALLOC (NULL); + /* ----------- Analyze loops. ----------- */ /* If some loop was duplicated, it gets bigger number @@ -2041,6 +2058,8 @@ vectorize_loops (struct loops *loops) /* ----------- Finalize. ----------- */ + BITMAP_FREE (vect_vnames_to_rename); + for (i = 1; i < vect_loops_num; i++) { struct loop *loop = loops->parray[i]; diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h index 5fdca3d6502..be42b96dcba 100644 --- a/gcc/tree-vectorizer.h +++ b/gcc/tree-vectorizer.h @@ -263,6 +263,9 @@ extern enum verbosity_levels vect_verbosity_level; /* Number of loops, at the beginning of vectorization. */ extern unsigned int vect_loops_num; +/* Bitmap of virtual variables to be renamed. */ +extern bitmap vect_vnames_to_rename; + /*-----------------------------------------------------------------*/ /* Function prototypes. */ /*-----------------------------------------------------------------*/