diff mbox

[02/06] New field in struct dependence_info indicating fixed length access

Message ID DB5PR0801MB27426F0B1519AF12AAD1421DE78C0@DB5PR0801MB2742.eurprd08.prod.outlook.com
State New
Headers show

Commit Message

Bin Cheng Aug. 14, 2017, 9:19 a.m. UTC
Hi,
This simple patch adds new field in struct dependence_info.  The new field
indicates if non-dependence information is only valid for fixed memory access
length of this reference.  There is a concern that this costs an additional
byte for all tree nodes, but I do not know easy way out because we need to
differentiate dependence_info derived from runtime alias check with others
derived from restrict pointer.
Bootstrap and test in series.  any comment?

Thanks,
bin
2017-08-10  Bin Cheng  <bin.cheng@arm.com>

	* tree-core.h (struct tree_base.dependence_info): New field.
	* tree.c (copy_node): Reset dependence info for fixed length
	memory access.
	* tree.h (MR_DEPENDENCE_FIXED_LENGTH_P): New macro.

Comments

Richard Biener Aug. 21, 2017, 1:10 p.m. UTC | #1
On Mon, Aug 14, 2017 at 11:19 AM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> This simple patch adds new field in struct dependence_info.  The new field
> indicates if non-dependence information is only valid for fixed memory access
> length of this reference.  There is a concern that this costs an additional
> byte for all tree nodes, but I do not know easy way out because we need to
> differentiate dependence_info derived from runtime alias check with others
> derived from restrict pointer.
> Bootstrap and test in series.  any comment?

This increases each tree node by 8 bytes, so no.  You'd have to carve the
bit away from either clique or base or find a bit elsewhere.

Note I do not understand the comment.

IIRC we discussed this in the context of versioning for aliasing where
for example vectorizer alias checks are performed with a min. dependence
distance in mind.  So when marking refs as non-aliasing we have to ensure
the info still holds when unrolling the loop n > min. dependence distance time
which is ensured by clearing the non-alias info.

Basically the versioned loop copy now adheres to safelen = vect-factor and
the question is what safelen translates to (see also PR81877 for some fun
around safelen).

Richard.

> Thanks,
> bin
> 2017-08-10  Bin Cheng  <bin.cheng@arm.com>
>
>         * tree-core.h (struct tree_base.dependence_info): New field.
>         * tree.c (copy_node): Reset dependence info for fixed length
>         memory access.
>         * tree.h (MR_DEPENDENCE_FIXED_LENGTH_P): New macro.
diff mbox

Patch

From 52073da1294a43723a5ee6a244c561f9b495f5b6 Mon Sep 17 00:00:00 2001
From: Bin Cheng <binche01@e108451-lin.cambridge.arm.com>
Date: Tue, 13 Jun 2017 15:56:42 +0100
Subject: [PATCH 2/6] fixed-length-dep-info-20170801.txt

---
 gcc/tree-core.h | 10 ++++++++--
 gcc/tree.c      |  8 ++++++++
 gcc/tree.h      |  3 +++
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-core.h b/gcc/tree-core.h
index 278d0c9..6200cb5 100644
--- a/gcc/tree-core.h
+++ b/gcc/tree-core.h
@@ -981,14 +981,20 @@  struct GTY(()) tree_base {
     /* Internal function code.  */
     enum internal_fn ifn;
 
-    /* The following two fields are used for MEM_REF and TARGET_MEM_REF
+    /* The first two fields are used for MEM_REF and TARGET_MEM_REF
        expression trees and specify known data non-dependences.  For
        two memory references in a function they are known to not
        alias if dependence_info.clique are equal and dependence_info.base
-       are distinct.  */
+       are distinct.  The third field is used for marking that data
+       non-dependences info only holds within the fixed access length
+       of this reference.  In other words, we should reset this info
+       whenever the MEM_REF and TARGET_MEM_REF are copied because we
+       don't know if it's used to build data reference accessing out-
+       side of fixed length.  */
     struct {
       unsigned short clique;
       unsigned short base;
+      bool fixed_length_p;
     } dependence_info;
   } GTY((skip(""))) u;
 };
diff --git a/gcc/tree.c b/gcc/tree.c
index c493edd..9c4f248 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1211,6 +1211,14 @@  copy_node (tree node MEM_STAT_DECL)
 	memcpy (TREE_OPTIMIZATION (t), TREE_OPTIMIZATION (node),
 		sizeof (struct cl_optimization));
       }
+  else if ((code == MEM_REF || code == TARGET_MEM_REF)
+	   && MR_DEPENDENCE_FIXED_LENGTH_P (t))
+    {
+      /* Reset dependence information for copying.  */
+      MR_DEPENDENCE_CLIQUE (t) = 0;
+      MR_DEPENDENCE_BASE (t) = 0;
+      MR_DEPENDENCE_FIXED_LENGTH_P (t) = false;
+    }
 
   return t;
 }
diff --git a/gcc/tree.h b/gcc/tree.h
index 46debc1..641b7ce 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1211,6 +1211,9 @@  extern void protected_set_expr_location (tree, location_t);
   (TREE_CHECK2 (NODE, MEM_REF, TARGET_MEM_REF)->base.u.dependence_info.clique)
 #define MR_DEPENDENCE_BASE(NODE) \
   (TREE_CHECK2 (NODE, MEM_REF, TARGET_MEM_REF)->base.u.dependence_info.base)
+#define MR_DEPENDENCE_FIXED_LENGTH_P(NODE) \
+  (TREE_CHECK2 (NODE, MEM_REF, \
+		TARGET_MEM_REF)->base.u.dependence_info.fixed_length_p)
 
 /* The operands of a BIND_EXPR.  */
 #define BIND_EXPR_VARS(NODE) (TREE_OPERAND (BIND_EXPR_CHECK (NODE), 0))
-- 
1.9.1