Patchwork Fix PR53708

login
register
mail settings
Submitter Richard Guenther
Date June 19, 2012, 9:19 a.m.
Message ID <alpine.LNX.2.00.1206191117570.28884@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/165699/
State New
Headers show

Comments

Richard Guenther - June 19, 2012, 9:19 a.m.
We are too eager to bump alignment of some decls when vectorizing.
The fix is to not bump alignment of decls the user explicitely
aligned or that are used in an unknown way.

Bootstrapped and tested on i686-darwin9 and x86_64-apple-darwin10
and powerpc-apple-darwin9 by darwin folks, applied.

Richard.

2012-06-19  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/53708
	* tree-vect-data-refs.c (vect_can_force_dr_alignment_p): Preserve
	user-supplied alignment and alignment of decls with the used
	attribute.
Richard Sandiford - June 19, 2012, 10:18 a.m.
Richard Guenther <rguenther@suse.de> writes:
> We are too eager to bump alignment of some decls when vectorizing.
> The fix is to not bump alignment of decls the user explicitely
> aligned or that are used in an unknown way.

I thought attribute((__aligned__)) only set a minimum alignment
for variables?  Most usees I've seen have been trying to get
better performance from higher alignment, so it might not go
down well if the attribute stopped the vectoriser from increasing
the alignment still further.

Richard
Richard Guenther - June 19, 2012, 10:22 a.m.
On Tue, 19 Jun 2012, Richard Sandiford wrote:

> Richard Guenther <rguenther@suse.de> writes:
> > We are too eager to bump alignment of some decls when vectorizing.
> > The fix is to not bump alignment of decls the user explicitely
> > aligned or that are used in an unknown way.
> 
> I thought attribute((__aligned__)) only set a minimum alignment
> for variables?  Most usees I've seen have been trying to get
> better performance from higher alignment, so it might not go
> down well if the attribute stopped the vectoriser from increasing
> the alignment still further.

That's what the documentation says indeed.  I'm not sure which
part of the patch fixes the ObjC failures where the alignment
is part of the ABI (and I suppose ObjC then mis-uses the aligned
attribute?).

Richard.

Patch

Index: gcc/tree-vect-data-refs.c
===================================================================
--- gcc/tree-vect-data-refs.c	(revision 188733)
+++ gcc/tree-vect-data-refs.c	(working copy)
@@ -4731,6 +4720,12 @@  vect_can_force_dr_alignment_p (const_tre
   if (TREE_ASM_WRITTEN (decl))
     return false;
 
+  /* Do not override explicit alignment set by the user or the alignment
+     as specified by the ABI when the used attribute is set.  */
+  if (DECL_USER_ALIGN (decl)
+      || DECL_PRESERVE_P (decl))
+    return false;
+
   if (TREE_STATIC (decl))
     return (alignment <= MAX_OFILE_ALIGNMENT);
   else