diff options
author | dorit <dorit@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-03 20:35:05 +0000 |
---|---|---|
committer | dorit <dorit@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-03 20:35:05 +0000 |
commit | 9896f25bbd2ccf9ac0d487e0fdbdf048386d28c7 (patch) | |
tree | 5600c4515b0df41a7300352395b0f3c145a96196 /gcc/cgraphunit.c | |
parent | f03c0a41f8c4ff72fae7b0e8485a35e241cb06bb (diff) | |
download | gcc-9896f25bbd2ccf9ac0d487e0fdbdf048386d28c7.tar.gz |
PR tree-optimization/27770
* tree-vectorizer.h (get_vectype_for_scalar_type): Function
declaration removed (moved to tree-flow.h).
(vect_can_force_dr_alignment_p): Likewise.
* tree-flow.h (get_vectype_for_scalar_type): New function declaration
(moved from tree-vectorizer.h).
(vect_can_force_dr_alignment_p): Likewise.
* tree-vectorizer.c (vect_print_dump_info): Allow calling this function
from outside the vectorizer - in particular from cgraph stage.
* tree-vect-analyze.c (vect_compute_data_ref_alignment): Don't increase
the alignment of global arrays when -fsection-anchors is enabled.
* cgraphunit.c (cgraph_increase_alignment): New function.
(cgraph_optimize): Call cgraph_increase_alignment.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@115910 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cgraphunit.c')
-rw-r--r-- | gcc/cgraphunit.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c index 256850224db..ddaecd3aa1c 100644 --- a/gcc/cgraphunit.c +++ b/gcc/cgraphunit.c @@ -172,6 +172,7 @@ static void cgraph_mark_functions_to_output (void); static void cgraph_expand_function (struct cgraph_node *); static tree record_reference (tree *, int *, void *); static void cgraph_output_pending_asms (void); +static void cgraph_increase_alignment (void); /* Records tree nodes seen in record_reference. Simply using walk_tree_without_duplicates doesn't guarantee each node is visited @@ -1506,6 +1507,7 @@ cgraph_optimize (void) /* This pass remove bodies of extern inline functions we never inlined. Do this later so other IPA passes see what is really going on. */ cgraph_remove_unreachable_nodes (false, dump_file); + cgraph_increase_alignment (); cgraph_global_info_ready = true; if (cgraph_dump_file) { @@ -1565,6 +1567,51 @@ cgraph_optimize (void) #endif } +/* Increase alignment of global arrays to improve vectorization potential. + TODO: + - Consider also structs that have an array field. + - Use ipa analysis to prune arrays that can't be vectorized? + This should involve global alignment analysis and in the future also + array padding. */ + +static void +cgraph_increase_alignment (void) +{ + if (flag_section_anchors && flag_tree_vectorize) + { + struct cgraph_varpool_node *vnode; + + /* Increase the alignment of all global arrays for vectorization. */ + for (vnode = cgraph_varpool_nodes_queue; + vnode; + vnode = vnode->next_needed) + { + tree vectype, decl = vnode->decl; + unsigned int alignment; + + if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE) + continue; + vectype = get_vectype_for_scalar_type (TREE_TYPE (TREE_TYPE (decl))); + if (!vectype) + continue; + alignment = TYPE_ALIGN (vectype); + if (DECL_ALIGN (decl) >= alignment) + continue; + + if (vect_can_force_dr_alignment_p (decl, alignment)) + { + DECL_ALIGN (decl) = TYPE_ALIGN (vectype); + DECL_USER_ALIGN (decl) = 1; + if (cgraph_dump_file) + { + fprintf (cgraph_dump_file, "Increasing alignment of decl: "); + print_generic_expr (cgraph_dump_file, decl, TDF_SLIM); + } + } + } + } +} + /* Generate and emit a static constructor or destructor. WHICH must be one of 'I' or 'D'. BODY should be a STATEMENT_LIST containing GENERIC statements. */ |