diff mbox

Fix vectorizer conditions on updating alignment

Message ID 20140616092426.GA19561@kam.mff.cuni.cz
State New
Headers show

Commit Message

Jan Hubicka June 16, 2014, 9:24 a.m. UTC
> On Fri, Jun 13, 2014 at 12:14 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
> > Hi,
> > while updating vect_can_force_dr_alignment_p for section API I noticed the
> > predicate is bit confused about when it can update the alignment.
> >
> > We need to check that decl_binds_to_current_def_p and in case we compile
> > a partition also that the symbol is not homed in other partition.
> > Previous code was wrong i.e. for COMDATs, weaks or -fpic.
> >
> > Also when having an alias, only way to promote the alignment is to bump
> > up alignment of target.
> >
> > On the other hand comment about DECL_IN_CONSTANT_POOL seems confused - we have
> > no sharing across partitions. I assume it was old hack and removed it.
> 
> I don't think that code was confused.  It's because of the way we emit
> the constant pool and use its hash (we duplicate the decl).  Do a svn
> blame and see for the associated PR which you now broke again
> I guess.  It wasn't about LTO I think.

It is middle-end/50494.

I have re-instantiated the check and also added back TREE_ASM_WRITTEN that is needed
in the case of -fno-toplevel-reorder.  I will try to look into the constant pool output
machinery but indeed it is a nasty problem.

Thanks,
Honza

Comments

James Greenhalgh June 24, 2014, 10:35 a.m. UTC | #1
On Mon, Jun 16, 2014 at 10:24:26AM +0100, Jan Hubicka wrote:
> > On Fri, Jun 13, 2014 at 12:14 AM, Jan Hubicka <hubicka@ucw.cz> wrote:
> > > Hi,
> > > while updating vect_can_force_dr_alignment_p for section API I noticed the
> > > predicate is bit confused about when it can update the alignment.
> > >
> > > We need to check that decl_binds_to_current_def_p and in case we compile
> > > a partition also that the symbol is not homed in other partition.
> > > Previous code was wrong i.e. for COMDATs, weaks or -fpic.
> > >
> > > Also when having an alias, only way to promote the alignment is to bump
> > > up alignment of target.
> > >
> > > On the other hand comment about DECL_IN_CONSTANT_POOL seems confused - we have
> > > no sharing across partitions. I assume it was old hack and removed it.
> > 
> > I don't think that code was confused.  It's because of the way we emit
> > the constant pool and use its hash (we duplicate the decl).  Do a svn
> > blame and see for the associated PR which you now broke again
> > I guess.  It wasn't about LTO I think.
> 
> It is middle-end/50494.
> 
> I have re-instantiated the check and also added back TREE_ASM_WRITTEN that is needed
> in the case of -fno-toplevel-reorder.  I will try to look into the constant pool output
> machinery but indeed it is a nasty problem.
> 
> Thanks,
> Honza

Hi Honza,

This patch has caused a number of vector tests to start failing for -fPIC
variants of the testsuite. (I'm running aarch64-none-elf,
aarch64-none-linux-gnu, arm-none-eabi, arm-none-linux-gnueabihf)

The full set of tests which have started failing for me are attached, a sample
failure looks like:

FAIL: gcc.dg/vect/vect-109.c scan-tree-dump-times vect "Vectorizing an unaligned access" 3

Looking on test-results I see similar problems on the i32coreavx target:

https://gcc.gnu.org/ml/gcc-testresults/2014-06/msg02097.html

Thanks,
James


> 
> Index: ChangeLog
> ===================================================================
> --- ChangeLog	(revision 211689)
> +++ ChangeLog	(working copy)
> @@ -1,5 +1,10 @@
>  2014-06-15  Jan Hubicka  <hubicka@ucw.cz>
>  
> +	* tree-vect-data-refs.c (vect_can_force_dr_alignment_p): Check again
> +	DECL_IN_CONSTANT_POOL and TREE_ASM_WRITTEN.
> +
> +2014-06-15  Jan Hubicka  <hubicka@ucw.cz>
> +
>  	* c-family/c-common.c (handle_tls_model_attribute): Use set_decl_tls_model.
>  	* cgraph.h (struct varpool_node): Add tls_model.
>  	* tree.c (decl_tls_model, set_decl_tls_model): New functions.
> Index: tree-vect-data-refs.c
> ===================================================================
> --- tree-vect-data-refs.c	(revision 211688)
> +++ tree-vect-data-refs.c	(working copy)
> @@ -5317,7 +5317,13 @@ vect_can_force_dr_alignment_p (const_tre
>    if (TREE_CODE (decl) != VAR_DECL)
>      return false;
>  
> -  gcc_assert (!TREE_ASM_WRITTEN (decl));
> +  /* With -fno-toplevel-reorder we may have already output the constant.  */
> +  if (TREE_ASM_WRITTEN (decl))
> +    return false;
> +
> +  /* Constant pool entries may be shared and not properly merged by LTO.  */
> +  if (DECL_IN_CONSTANT_POOL (decl))
> +    return false;
>  
>    if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
>      {
>
Test Run By pdtltest on Mon Jun 23 20:00:58 2014
Target is aarch64-none-elf
Host   is x86_64-unknown-linux-gnu

		=== gcc Tests for aarch64-elf-foundation/-mcmodel=tiny/-fPIC ===

FAIL: gcc.dg/vect/vect-109.c scan-tree-dump-times vect "Vectorizing an unaligned access" 3
FAIL: gcc.dg/vect/vect-13.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-17.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-18.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-19.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-2-big-array.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-2.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-20.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-21.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-22.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-27.c scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-29.c scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-3.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-4.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-5.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-7.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-72.c scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-73-big-array.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-73.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-77-global.c scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-78-global.c scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-86.c scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-align-1.c scan-tree-dump-times vect "Vectorizing an unaligned access" 1
FAIL: gcc.dg/vect/vect-align-3.c scan-tree-dump-not vect "vect_do_peeling_for_loop_bound"
FAIL: gcc.dg/vect/vect-align-3.c scan-tree-dump-not vect "loop peeled for vectorization"
FAIL: gcc.dg/vect/vect-all-big-array.c scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-all.c scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-multitypes-1.c scan-tree-dump-times vect "Vectorizing an unaligned access" 4
FAIL: gcc.dg/vect/vect-multitypes-4.c scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-multitypes-4.c scan-tree-dump-times vect "Vectorizing an unaligned access" 4
FAIL: gcc.dg/vect/vect-peel-3.c scan-tree-dump-times vect "Vectorizing an unaligned access" 1
FAIL: gcc.dg/vect/vect-peel-4.c scan-tree-dump-times vect "Vectorizing an unaligned access" 1
FAIL: gcc.dg/vect/vect-peel-4.c scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/slp-25.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/slp-25.c scan-tree-dump-times vect "Alignment of access forced using peeling" 2
FAIL: gcc.dg/vect/vect-109.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 3
FAIL: gcc.dg/vect/vect-13.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-17.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-18.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-19.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-2-big-array.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-2.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-20.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-21.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-22.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-27.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-29.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-3.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-4.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-5.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-7.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-72.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-73-big-array.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-73.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/vect-77-global.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-78-global.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-86.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-align-1.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 1
FAIL: gcc.dg/vect/vect-align-3.c -flto -ffat-lto-objects  scan-tree-dump-not vect "vect_do_peeling_for_loop_bound"
FAIL: gcc.dg/vect/vect-align-3.c -flto -ffat-lto-objects  scan-tree-dump-not vect "loop peeled for vectorization"
FAIL: gcc.dg/vect/vect-all-big-array.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-all.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-multitypes-1.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 4
FAIL: gcc.dg/vect/vect-multitypes-4.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/vect-multitypes-4.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 4
FAIL: gcc.dg/vect/vect-peel-3.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 1
FAIL: gcc.dg/vect/vect-peel-4.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 1
FAIL: gcc.dg/vect/vect-peel-4.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/slp-25.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/slp-25.c -flto -ffat-lto-objects  scan-tree-dump-times vect "Alignment of access forced using peeling" 2
FAIL: gcc.dg/vect/wrapv-vect-7.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/no-section-anchors-vect-31.c scan-tree-dump-times vect "Alignment of access forced using peeling" 2
FAIL: gcc.dg/vect/no-section-anchors-vect-34.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/no-section-anchors-vect-36.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/no-section-anchors-vect-36.c scan-tree-dump-times vect "Alignment of access forced using peeling" 0
FAIL: gcc.dg/vect/no-section-anchors-vect-64.c scan-tree-dump-times vect "Alignment of access forced using peeling" 2
FAIL: gcc.dg/vect/no-section-anchors-vect-65.c scan-tree-dump-times vect "Vectorizing an unaligned access" 0
FAIL: gcc.dg/vect/no-section-anchors-vect-69.c scan-tree-dump-times vect "Alignment of access forced using peeling" 2
diff mbox

Patch

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 211689)
+++ ChangeLog	(working copy)
@@ -1,5 +1,10 @@ 
 2014-06-15  Jan Hubicka  <hubicka@ucw.cz>
 
+	* tree-vect-data-refs.c (vect_can_force_dr_alignment_p): Check again
+	DECL_IN_CONSTANT_POOL and TREE_ASM_WRITTEN.
+
+2014-06-15  Jan Hubicka  <hubicka@ucw.cz>
+
 	* c-family/c-common.c (handle_tls_model_attribute): Use set_decl_tls_model.
 	* cgraph.h (struct varpool_node): Add tls_model.
 	* tree.c (decl_tls_model, set_decl_tls_model): New functions.
Index: tree-vect-data-refs.c
===================================================================
--- tree-vect-data-refs.c	(revision 211688)
+++ tree-vect-data-refs.c	(working copy)
@@ -5317,7 +5317,13 @@  vect_can_force_dr_alignment_p (const_tre
   if (TREE_CODE (decl) != VAR_DECL)
     return false;
 
-  gcc_assert (!TREE_ASM_WRITTEN (decl));
+  /* With -fno-toplevel-reorder we may have already output the constant.  */
+  if (TREE_ASM_WRITTEN (decl))
+    return false;
+
+  /* Constant pool entries may be shared and not properly merged by LTO.  */
+  if (DECL_IN_CONSTANT_POOL (decl))
+    return false;
 
   if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
     {