This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix vectorizer alignment update wrt section anchors
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org, richard dot sandiford at arm dot com
- Date: Mon, 9 Mar 2015 04:38:57 +0100
- Subject: Fix vectorizer alignment update wrt section anchors
- Authentication-results: sourceware.org; auth=none
Hi,
this patch avoids notice_global_symbol to create DECL_RTL prior IPA
optimization. Consequently symtab_node::can_increase_alignment_p can check for
presence of DECL_RTL with section anchor. This makes it possible to bump up
alignment in tree-vect-data-refs.c in some cases (when DECL_RTL is not computed
yet).
I suppose vectorizer can also be updated to just bump up alingmnet of the
section and then use the known offset within the section.
Bootstrapped/regtested x86_64-linux and ppc64-linux, will commit it tomorrow
if there are no better ideas for fix.
PR tree-optimization/65355
* varasm.c (notice_global_symbol): Do not produce RTL.
* symtab.c (symtab_node::can_increase_alignment_p): Check for section
anchor.
* tree-vect-data-refs.c (vect_compute_data_ref_alignment): Do not
check for section anchors.
* gcc.dg/vect/section-anchors-vect-69.c: Update template.
Index: testsuite/gcc.dg/vect/section-anchors-vect-69.c
===================================================================
--- testsuite/gcc.dg/vect/section-anchors-vect-69.c (revision 221274)
+++ testsuite/gcc.dg/vect/section-anchors-vect-69.c (working copy)
@@ -115,6 +115,6 @@ int main (void)
/* { dg-final { scan-tree-dump-times "Vectorizing an unaligned access" 0 "vect" } } */
/* Alignment forced using versioning until the pass that increases alignment
is extended to handle structs. */
-/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 4 "vect" { target {vect_int && vector_alignment_reachable } } } } */
+/* { dg-final { scan-tree-dump-times "Alignment of access forced using peeling" 2 "vect" { target {vect_int && vector_alignment_reachable } } } } */
/* { dg-final { scan-tree-dump-times "Alignment of access forced using versioning" 4 "vect" { target {vect_int && {! vector_alignment_reachable} } } } } */
/* { dg-final { cleanup-tree-dump "vect" } } */
Index: varasm.c
===================================================================
--- varasm.c (revision 221269)
+++ varasm.c (working copy)
@@ -1630,35 +1630,30 @@ default_ctor_section_asm_out_constructor
void
notice_global_symbol (tree decl)
{
- const char **type = &first_global_object_name;
+ const char **t = &first_global_object_name;
if (first_global_object_name
|| !TREE_PUBLIC (decl)
|| DECL_EXTERNAL (decl)
|| !DECL_NAME (decl)
+ || (TREE_CODE (decl) == VAR_DECL && DECL_HARD_REGISTER (decl))
|| (TREE_CODE (decl) != FUNCTION_DECL
&& (TREE_CODE (decl) != VAR_DECL
|| (DECL_COMMON (decl)
&& (DECL_INITIAL (decl) == 0
- || DECL_INITIAL (decl) == error_mark_node))))
- || !MEM_P (DECL_RTL (decl)))
+ || DECL_INITIAL (decl) == error_mark_node)))))
return;
/* We win when global object is found, but it is useful to know about weak
symbol as well so we can produce nicer unique names. */
if (DECL_WEAK (decl) || DECL_ONE_ONLY (decl) || flag_shlib)
- type = &weak_global_object_name;
+ t = &weak_global_object_name;
- if (!*type)
+ if (!*t)
{
- const char *p;
- const char *name;
- rtx decl_rtl = DECL_RTL (decl);
-
- p = targetm.strip_name_encoding (XSTR (XEXP (decl_rtl, 0), 0));
- name = ggc_strdup (p);
-
- *type = name;
+ tree id = DECL_ASSEMBLER_NAME (decl);
+ ultimate_transparent_alias_target (&id);
+ *t = ggc_strdup (targetm.strip_name_encoding (IDENTIFIER_POINTER (id)));
}
}
Index: symtab.c
===================================================================
--- symtab.c (revision 221268)
+++ symtab.c (working copy)
@@ -1924,6 +1924,13 @@ symtab_node::can_increase_alignment_p (v
if (TREE_ASM_WRITTEN (target->decl))
return false;
+ /* If target is already placed in an anchor, we can not touch its
+ alignment. */
+ if (DECL_RTL_SET_P (target->decl)
+ && MEM_P (DECL_RTL (target->decl))
+ && SYMBOL_REF_HAS_BLOCK_INFO_P (XEXP (DECL_RTL (target->decl), 0)))
+ return false;
+
/* Constant pool entries may be shared. */
if (DECL_IN_CONSTANT_POOL (target->decl))
return false;
Index: tree-vect-data-refs.c
===================================================================
--- tree-vect-data-refs.c (revision 221268)
+++ tree-vect-data-refs.c (working copy)
@@ -758,12 +758,7 @@ vect_compute_data_ref_alignment (struct
&& TREE_CODE (TREE_OPERAND (base, 0)) == ADDR_EXPR)
base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
- /* Do not change the alignment of global variables here if
- flag_section_anchors is enabled as we already generated
- RTL for other functions. Most global variables should
- have been aligned during the IPA increase_alignment pass. */
- if (!vect_can_force_dr_alignment_p (base, TYPE_ALIGN (vectype))
- || (TREE_STATIC (base) && flag_section_anchors))
+ if (!vect_can_force_dr_alignment_p (base, TYPE_ALIGN (vectype)))
{
if (dump_enabled_p ())
{