diff options
author | dorit <dorit@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-08-17 16:17:14 +0000 |
---|---|---|
committer | dorit <dorit@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-08-17 16:17:14 +0000 |
commit | c91e822398d80d51e7b0e0884fa3e8c7c32d6ae7 (patch) | |
tree | 49effbb8670b04dbfb66de531c733c3e4389a525 /gcc/tree-data-ref.c | |
parent | 867fd9060f9bdfef84dbea3354f5747c94d60a13 (diff) | |
download | gcc-c91e822398d80d51e7b0e0884fa3e8c7c32d6ae7.tar.gz |
* tree-vectorizer.c: New File: loop vectorization on SSAed GIMPLE trees.
* tree-vectorizer.h: New File: Same.
* Makefile.in (tree-vectorizer.c, tree-vectorizer.h): Add new files.
* common.opt (ftree-vectorize): New flag to enable vectorization.
* timevar.def (TV_TREE_VECTORIZATION): New dump file for vectorization
pass.
* tree-data-ref.h (init_data_ref): Additional argument.
(array_base_name_differ_p): Moved to tree-data-ref.c.
* tree-data-ref.c (array_base_name_differ_p): Revised.
(initialize_data_dependence_relation): Call array_base_name_differ_p
with an extra argument.
(analyze_all_data_dependences): Same.
(init_data_ref): Additional argument is_read to set DR_IS_READ.
* tree-ssa-phiopt.c (empty_block_p): Expose for usage out of this file.
* tree-flow.h (vectorize_loops, empty_block_p): Add declaration.
* tree-optimize.c (pass_vectorize): Schedule the vectorization pass.
* tree-pass.h (tree_opt_pass pass_vectorize): Declare the new
vectorization pass.
* tree-ssa-loop.c (tree_ssa_loop_init): Call scev_initialize.
(tree_ssa_loop_done): Call scev_finalize.
(tree_vectorize): Define the new vectorization pass.
* defaults.h (UNITS_PER_SIMD_WORD): Allow targets to specify the size of
the vector they support (until support for multiple vector sizes is
added to the vectorizer).
* config/i386/i386.h (UNITS_PER_SIMD_WORD): Define.
* config/rs6000/rs6000.h (UNITS_PER_SIMD_WORD): Define.
* invoke.texi (fdump-tree-vect, ftree-vectorize): Add
documentation.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@86131 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree-data-ref.c')
-rw-r--r-- | gcc/tree-data-ref.c | 114 |
1 files changed, 111 insertions, 3 deletions
diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 1f14bcb011d..c45762d8540 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -99,6 +99,110 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA static unsigned int data_ref_id = 0; +/* This is the simplest data dependence test: determines whether the + data references A and B access the same array/region. If can't determine - + return false; Otherwise, return true, and DIFFER_P will record + the result. This utility will not be necessary when alias_sets_conflict_p + will be less conservative. */ + +bool +array_base_name_differ_p (struct data_reference *a, + struct data_reference *b, + bool *differ_p) +{ + tree base_a = DR_BASE_NAME (a); + tree base_b = DR_BASE_NAME (b); + tree ta = TREE_TYPE (base_a); + tree tb = TREE_TYPE (base_b); + + + /** Determine if same base **/ + + /* array accesses: a[i],b[i] or pointer accesses: *a,*b. bases are a,b. */ + if (base_a == base_b) + { + *differ_p = false; + return true; + } + + /* pointer based accesses - (*p)[i],(*q)[j]. bases are (*p),(*q) */ + if (TREE_CODE (base_a) == INDIRECT_REF && TREE_CODE (base_b) == INDIRECT_REF + && TREE_OPERAND (base_a, 0) == TREE_OPERAND (base_b, 0)) + { + *differ_p = false; + return true; + } + + /* record/union based accesses - s.a[i], t.b[j]. bases are s.a,t.b. */ + if (TREE_CODE (base_a) == COMPONENT_REF && TREE_CODE (base_b) == COMPONENT_REF + && TREE_OPERAND (base_a, 0) == TREE_OPERAND (base_b, 0) + && TREE_OPERAND (base_a, 1) == TREE_OPERAND (base_b, 1)) + { + *differ_p = false; + return true; + } + + + /** Determine if different bases **/ + + /* at this point we know that base_a != base_b. However, pointer accesses + of the form x=(*p) and y=(*q), which bases are p and q, may still by pointing + to the same base. In SSAed GIMPLE p and q will be SSA_NAMES in this case. + Therefore, here we check if it's really two diferent declarations. */ + if (TREE_CODE (base_a) == VAR_DECL && TREE_CODE (base_b) == VAR_DECL) + { + *differ_p = true; + return true; + } + + /* compare two record/union bases s.a and t.b: + s != t or (a != b and s and t are not unions) */ + if (TREE_CODE (base_a) == COMPONENT_REF && TREE_CODE (base_b) == COMPONENT_REF + && ((TREE_CODE (TREE_OPERAND (base_a, 0)) == VAR_DECL + && TREE_CODE (TREE_OPERAND (base_b, 0)) == VAR_DECL + && TREE_OPERAND (base_a, 0) != TREE_OPERAND (base_b, 0)) + || (TREE_CODE (TREE_TYPE (TREE_OPERAND (base_a, 0))) == RECORD_TYPE + && TREE_CODE (TREE_TYPE (TREE_OPERAND (base_b, 0))) == RECORD_TYPE + && TREE_OPERAND (base_a, 1) != TREE_OPERAND (base_b, 1)))) + { + *differ_p = true; + return true; + } + + /* compare a record/union access and an array access. */ + if ((TREE_CODE (base_a) == VAR_DECL + && (TREE_CODE (base_b) == COMPONENT_REF + && TREE_CODE (TREE_OPERAND (base_b, 0)) == VAR_DECL)) + || (TREE_CODE (base_b) == VAR_DECL + && (TREE_CODE (base_a) == COMPONENT_REF + && TREE_CODE (TREE_OPERAND (base_a, 0)) == VAR_DECL))) + { + *differ_p = true; + return true; + } + + if (!alias_sets_conflict_p (get_alias_set (base_a), get_alias_set (base_b))) + { + *differ_p = true; + return true; + } + + /* An insn writing through a restricted pointer is "independent" of any + insn reading or writing through a different pointer, in the same + block/scope. + */ + if ((TREE_CODE (ta) == POINTER_TYPE && TYPE_RESTRICT (ta) + && !DR_IS_READ(a)) + || (TREE_CODE (tb) == POINTER_TYPE && TYPE_RESTRICT (tb) + && !DR_IS_READ(b))) + { + *differ_p = true; + return true; + } + + *differ_p = false; /* Don't know, but be conservative. */ + return false; +} /* Returns true iff A divides B. */ @@ -466,7 +570,8 @@ struct data_reference * init_data_ref (tree stmt, tree ref, tree base, - tree access_fn) + tree access_fn, + bool is_read) { struct data_reference *res; @@ -486,6 +591,7 @@ init_data_ref (tree stmt, VARRAY_TREE_INIT (DR_ACCESS_FNS (res), 5, "access_fns"); DR_BASE_NAME (res) = base; VARRAY_PUSH_TREE (DR_ACCESS_FNS (res), access_fn); + DR_IS_READ (res) = is_read; if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, ")\n"); @@ -532,6 +638,7 @@ initialize_data_dependence_relation (struct data_reference *a, struct data_reference *b) { struct data_dependence_relation *res; + bool differ_p; res = ggc_alloc (sizeof (struct data_dependence_relation)); DDR_A (res) = a; @@ -545,7 +652,7 @@ initialize_data_dependence_relation (struct data_reference *a, /* When the dimensions of A and B differ, we directly initialize the relation to "there is no dependence": chrec_known. */ else if (DR_NUM_DIMENSIONS (a) != DR_NUM_DIMENSIONS (b) - || array_base_name_differ_p (a, b)) + || (array_base_name_differ_p (a, b, &differ_p) && differ_p)) DDR_ARE_DEPENDENT (res) = chrec_known; else @@ -1842,9 +1949,10 @@ analyze_all_data_dependences (struct loops *loops) { struct data_reference *a = DDR_A (ddr); struct data_reference *b = DDR_B (ddr); + bool differ_p; if (DR_NUM_DIMENSIONS (a) != DR_NUM_DIMENSIONS (b) - || array_base_name_differ_p (a, b)) + || (array_base_name_differ_p (a, b, &differ_p) && differ_p)) nb_basename_differ++; else nb_bot_relations++; |