This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PR18173 - can't force alignment of global arrays with staticinitializer?





The reason why the vectorizer can't force the alignment of global arrays
with static initialization is that they are being assembled before
vectorization:

#1  0x103ba23c in cgraph_varpool_assemble_pending_decls () at
../../gcc/gcc/cgraph.c:620
#2  0x103be1f0 in cgraph_finalize_compilation_unit () at ../../gcc/
gcc/cgraphunit.c:680
#3  0x1001daa0 in pop_file_scope () at ../../gcc/gcc/c-decl.c:899
#4  0x10052ccc in c_common_parse_file (set_yydebug=12) at
../../gcc/gcc/c-opts.c:1097
#5  0x10356408 in toplev_main (argc=275382272, argv=0x106a0000) at
../../gcc/gcc/toplev.c:985
#6  0x10069b4c in main (argc=12, argv=0xffffb5d0) at
../../gcc/gcc/main.c:35


as opposed to other decls, which are being assembled after vectorization:

#1  0x103ba23c in cgraph_varpool_assemble_pending_decls () at
../../gcc/gcc/cgraph.c:620
#2  0x103567dc in toplev_main (argc=275382272, argv=0x106a0000) at
../../gcc/gcc/toplev.c:1000
#3  0x10069b4c in main (argc=13, argv=0xffffb650) at
../../gcc/gcc/main.c:35


So any changes to such decls during vectorization (be it setting DECL_ALIGN
or creating a new type with the new alignment) have no effect on the decl
layout.  Unless we can defer "assemble_variable" for these decls, looks
like something like the following patch will be required after all:

Changelog:

      * tree-vectorizer.c (vect_can_force_dr_alignment_p): Return false for
global
      decls with static initializers.

Patch:

*************** vect_can_force_dr_alignment_p (tree decl
*** 1510,1515 ****
--- 1509,1517 ----
    if (DECL_EXTERNAL (decl))
      return false;

+   if (DECL_FILE_SCOPE_P (decl) && DECL_INITIAL (decl))
+     return false;
+
    if (TREE_STATIC (decl))
      return (alignment <= MAX_OFILE_ALIGNMENT);
    else


Is this ok for mainline?


> I'm actually not sure why DECL_ALIGN exists, it should really always
> be equal to TYPE_ALIGN. What you do if you want to change the
> alignment is you create a new type that's the same as the previous one
> but with a different TYPE_ALIGN, and then change the decl's type, and
> then maybe re-layout the decl.

I can send a separate patch for that if required/desired for 4.0.


thanks,

dorit




                                                                                                                                  
                      Richard Henderson                                                                                           
                      <rth@redhat.com>         To:       Geoffrey Keating <geoffk@geoffk.org>                                     
                                               cc:       Dorit Naishlos/Haifa/IBM@IBMIL, gcc-patches@gcc.gnu.org                  
                      24/11/2004 03:55         Subject:  Re: PR18173 - can't force alignment of global arrays with static         
                                                initializer?                                                                      
                                                                                                                                  




On Tue, Nov 23, 2004 at 03:55:18PM -0800, Geoffrey Keating wrote:
> I'm actually not sure why DECL_ALIGN exists, it should really always
> be equal to TYPE_ALIGN.  What you do if you want to change the
> alignment is you create a new type that's the same as the previous one
> but with a different TYPE_ALIGN, and then change the decl's type, and
> then maybe re-layout the decl.

Yes.  Mark and Kenner have argued about this in the past at length.


r~



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]