Richard Guenther <rguent...@suse.de> wrote on 30/06/2011 06:24:50 PM:
> FYI, I'm testing the following which cures a fallout seen when > building SPEC2k6 with the committed patch. It's suboptimal for > j != 0 though - is there a way to get to the vectorized stmt > of the j == 0 iteration? Yes, I think we can simply use the stmt from the previous iteration, but we have to avoid creation of unnecessary vector loads. Even though multiple uses of that single load are still created, they are cleaned up later. (I didn't indent the code properly and only tested the patch on the vectorizer testsuite). Ira Index: tree-vect-stmts.c =================================================================== --- tree-vect-stmts.c (revision 175785) +++ tree-vect-stmts.c (working copy) @@ -4386,6 +4386,8 @@ vectorizable_load (gimple stmt, gimple_s for (j = 0; j < ncopies; j++) { /* 1. Create the vector or array pointer update chain. */ + if (!inv_p || bb_vinfo) + { if (j == 0) dataref_ptr = vect_create_data_ref_ptr (first_stmt, aggr_type, at_loop, offset, &dummy, gsi, @@ -4393,11 +4395,11 @@ vectorizable_load (gimple stmt, gimple_s else dataref_ptr = bump_vector_ptr (dataref_ptr, ptr_incr, gsi, stmt, TYPE_SIZE_UNIT (aggr_type)); - + } if (strided_load || slp_perm) dr_chain = VEC_alloc (tree, heap, vec_num); - if (load_lanes_p) + if (load_lanes_p && (!inv_p || bb_vinfo)) { tree vec_array; @@ -4426,6 +4428,8 @@ vectorizable_load (gimple stmt, gimple_s { for (i = 0; i < vec_num; i++) { + if (!inv_p || bb_vinfo) + { if (i > 0) dataref_ptr = bump_vector_ptr (dataref_ptr, ptr_incr, gsi, stmt, NULL_TREE); @@ -4570,18 +4574,22 @@ vectorizable_load (gimple stmt, gimple_s msq = lsq; } } - + } + /* 4. Handle invariant-load. */ - if (inv_p && !bb_vinfo) - { - tree vec_inv; - gimple_stmt_iterator gsi2 = *gsi; - gcc_assert (!strided_load); - gsi_next (&gsi2); - vec_inv = build_vector_from_val (vectype, scalar_dest); - new_temp = vect_init_vector (stmt, vec_inv, - vectype, &gsi2); - new_stmt = SSA_NAME_DEF_STMT (new_temp); + else + { + if (j==0) + { + tree vec_inv; + gimple_stmt_iterator gsi2 = *gsi; + gcc_assert (!strided_load); + gsi_next (&gsi2); + vec_inv = build_vector_from_val (vectype, scalar_dest); + new_temp = vect_init_vector (stmt, vec_inv, + vectype, &gsi2); + new_stmt = SSA_NAME_DEF_STMT (new_temp); + } } if (negative) > > Thanks, > Richard. > > 2011-06-30 Richard Guenther <rguent...@suse.de> > > * tree-vect-stmts.c (vectorizable_load): Remove unnecessary > assert. > > Index: gcc/tree-vect-stmts.c > =================================================================== > --- gcc/tree-vect-stmts.c (revision 175709) > +++ gcc/tree-vect-stmts.c (working copy) > @@ -4574,19 +4574,14 @@ vectorizable_load (gimple stmt, gimple_s > /* 4. Handle invariant-load. */ > if (inv_p && !bb_vinfo) > { > + tree vec_inv; > + gimple_stmt_iterator gsi2 = *gsi; > gcc_assert (!strided_load); > - if (j == 0) > - { > - tree vec_inv; > - gimple_stmt_iterator gsi2 = *gsi; > - gsi_next (&gsi2); > - vec_inv = build_vector_from_val (vectype, scalar_dest); > - new_temp = vect_init_vector (stmt, vec_inv, > - vectype, &gsi2); > - new_stmt = SSA_NAME_DEF_STMT (new_temp); > - } > - else > - gcc_unreachable (); /* FORNOW. */ > + gsi_next (&gsi2); > + vec_inv = build_vector_from_val (vectype, scalar_dest); > + new_temp = vect_init_vector (stmt, vec_inv, > + vectype, &gsi2); > + new_stmt = SSA_NAME_DEF_STMT (new_temp); > } > > if (negative)