diff options
author | Ira Rosen <irar@il.ibm.com> | 2008-06-16 10:39:07 +0000 |
---|---|---|
committer | Ira Rosen <irar@gcc.gnu.org> | 2008-06-16 10:39:07 +0000 |
commit | 54269f054f818c6bc958242809b5f766dc758cf4 (patch) | |
tree | f7ada106868dc6feee115753eee2066ceab6839d /gcc/tree-vect-transform.c | |
parent | 7364f2868c8ac21e519725d716bc13f02b19684f (diff) | |
download | gcc-54269f054f818c6bc958242809b5f766dc758cf4.zip gcc-54269f054f818c6bc958242809b5f766dc758cf4.tar.gz gcc-54269f054f818c6bc958242809b5f766dc758cf4.tar.bz2 |
re PR tree-optimization/36493 (vectorizer aliasing bug)
PR tree-optimization/36493
* tree-vect-transform.c (vect_create_data_ref_ptr): Remove TYPE from
the arguments list. Use VECTYPE to create vector pointer.
(vectorizable_store): Fail if accesses through a pointer to vectype
do not alias the original memory reference operands.
Call vect_create_data_ref_ptr without the removed argument.
(vectorizable_load): Likewise.
(vect_setup_realignment): Call vect_create_data_ref_ptr without the
removed argument.
From-SVN: r136843
Diffstat (limited to 'gcc/tree-vect-transform.c')
-rw-r--r-- | gcc/tree-vect-transform.c | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/gcc/tree-vect-transform.c b/gcc/tree-vect-transform.c index 450af30..4110b335 100644 --- a/gcc/tree-vect-transform.c +++ b/gcc/tree-vect-transform.c @@ -49,7 +49,7 @@ along with GCC; see the file COPYING3. If not see static bool vect_transform_stmt (tree, block_stmt_iterator *, bool *, slp_tree); static tree vect_create_destination_var (tree, tree); static tree vect_create_data_ref_ptr - (tree, struct loop*, tree, tree *, tree *, bool, tree, bool *); + (tree, struct loop*, tree, tree *, tree *, bool, bool *); static tree vect_create_addr_base_for_vector_ref (tree, tree *, tree, struct loop *); static tree vect_get_new_vect_var (tree, enum vect_var_kind, const char *); @@ -951,7 +951,6 @@ vect_create_addr_base_for_vector_ref (tree stmt, by the data-ref in STMT. 4. ONLY_INIT: indicate if vp is to be updated in the loop, or remain pointing to the initial address. - 5. TYPE: if not NULL indicates the required type of the data-ref Output: 1. Declare a new ptr to vector_type, and have it point to the base of the @@ -981,7 +980,7 @@ vect_create_addr_base_for_vector_ref (tree stmt, static tree vect_create_data_ref_ptr (tree stmt, struct loop *at_loop, tree offset, tree *initial_address, tree *ptr_incr, - bool only_init, tree type, bool *inv_p) + bool only_init, bool *inv_p) { tree base_name; stmt_vec_info stmt_info = vinfo_for_stmt (stmt); @@ -1040,10 +1039,8 @@ vect_create_data_ref_ptr (tree stmt, struct loop *at_loop, } /** (1) Create the new vector-pointer variable: **/ - if (type) - vect_ptr_type = build_pointer_type (type); - else - vect_ptr_type = build_pointer_type (vectype); + vect_ptr_type = build_pointer_type (vectype); + vect_ptr = vect_get_new_vect_var (vect_ptr_type, vect_pointer_var, get_name (base_name)); add_referenced_var (vect_ptr); @@ -4756,6 +4753,24 @@ vectorizable_store (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt, return false; } + /* If accesses through a pointer to vectype do not alias the original + memory reference we have a problem. */ + if (get_alias_set (vectype) != get_alias_set (TREE_TYPE (scalar_dest)) + && !alias_set_subset_of (get_alias_set (vectype), + get_alias_set (TREE_TYPE (scalar_dest)))) + { + if (vect_print_dump_info (REPORT_DETAILS)) + fprintf (vect_dump, "vector type does not alias scalar type"); + return false; + } + + if (!useless_type_conversion_p (TREE_TYPE (op), TREE_TYPE (scalar_dest))) + { + if (vect_print_dump_info (REPORT_DETAILS)) + fprintf (vect_dump, "operands of different types"); + return false; + } + vec_mode = TYPE_MODE (vectype); /* FORNOW. In some cases can vectorize even if data-type not supported (e.g. - array initialization with 0). */ @@ -4930,9 +4945,10 @@ vectorizable_store (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt, next_stmt = DR_GROUP_NEXT_DR (vinfo_for_stmt (next_stmt)); } } + dataref_ptr = vect_create_data_ref_ptr (first_stmt, NULL, NULL_TREE, - &dummy, &ptr_incr, false, - TREE_TYPE (vec_oprnd), &inv_p); + &dummy, &ptr_incr, false, + &inv_p); gcc_assert (!inv_p); } else @@ -5170,7 +5186,7 @@ vect_setup_realignment (tree stmt, block_stmt_iterator *bsi, pe = loop_preheader_edge (loop_for_initial_load); vec_dest = vect_create_destination_var (scalar_dest, vectype); ptr = vect_create_data_ref_ptr (stmt, loop_for_initial_load, NULL_TREE, - &init_addr, &inc, true, NULL_TREE, &inv_p); + &init_addr, &inc, true, &inv_p); data_ref = build1 (ALIGN_INDIRECT_REF, vectype, ptr); new_stmt = build_gimple_modify_stmt (vec_dest, data_ref); new_temp = make_ssa_name (vec_dest, new_stmt); @@ -5619,6 +5635,17 @@ vectorizable_load (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt, return false; } + /* If accesses through a pointer to vectype do not alias the original + memory reference we have a problem. */ + if (get_alias_set (vectype) != get_alias_set (scalar_type) + && !alias_set_subset_of (get_alias_set (vectype), + get_alias_set (scalar_type))) + { + if (vect_print_dump_info (REPORT_DETAILS)) + fprintf (vect_dump, "vector type does not alias scalar type"); + return false; + } + /* Check if the load is a part of an interleaving chain. */ if (STMT_VINFO_STRIDED_ACCESS (stmt_info)) { @@ -5811,7 +5838,7 @@ vectorizable_load (tree stmt, block_stmt_iterator *bsi, tree *vec_stmt, dataref_ptr = vect_create_data_ref_ptr (first_stmt, at_loop, offset, &dummy, &ptr_incr, false, - NULL_TREE, &inv_p); + &inv_p); else dataref_ptr = bump_vector_ptr (dataref_ptr, ptr_incr, bsi, stmt, NULL_TREE); |