From 004a30422775d45c42d6156c06f4cf00a6594bf6 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Mon, 3 Jul 2017 13:36:26 +0000 Subject: Make dr_analyze_innermost operate on innermost_loop_behavior This means that callers to dr_analyze_innermost don't need a full data_reference and don't need to fill in any fields beforehand. 2017-07-03 Richard Sandiford gcc/ * tree-data-ref.h (dr_analyze_innermost): Replace the dr argument with a "innermost_loop_behavior *" and refeence tree. * tree-data-ref.c (dr_analyze_innermost): Likewise. (create_data_ref): Update call accordingly. * tree-predcom.c (find_looparound_phi): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249913 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-data-ref.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/tree-data-ref.h') diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h index 0013049053f..c8bb813e77c 100644 --- a/gcc/tree-data-ref.h +++ b/gcc/tree-data-ref.h @@ -322,7 +322,7 @@ typedef struct data_dependence_relation *ddr_p; #define DDR_REVERSED_P(DDR) (DDR)->reversed_p -bool dr_analyze_innermost (struct data_reference *, struct loop *); +bool dr_analyze_innermost (innermost_loop_behavior *, tree, struct loop *); extern bool compute_data_dependences_for_loop (struct loop *, bool, vec *, vec *, -- cgit v1.2.1 From a7e05ef215098046508869309183d6a1b83362c9 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Mon, 3 Jul 2017 13:36:36 +0000 Subject: Rename DR_ALIGNED_TO to DR_OFFSET_ALIGNMENT This patch renames DR_ALIGNED_TO to DR_OFFSET_ALIGNMENT, to avoid confusion with the upcoming DR_BASE_ALIGNMENT. Nothing needed the value as a tree, and the value is clipped to BIGGEST_ALIGNMENT (maybe it should be MAX_OFILE_ALIGNMENT?) so we might as well use an unsigned int instead. 2017-07-03 Richard Sandiford gcc/ * tree-data-ref.h (innermost_loop_behavior): Replace aligned_to with offset_alignment. (DR_ALIGNED_TO): Delete. (DR_OFFSET_ALIGNMENT): New macro. * tree-vectorizer.h (STMT_VINFO_DR_ALIGNED_TO): Delete. (STMT_VINFO_DR_OFFSET_ALIGNMENT): New macro. * tree-data-ref.c (dr_analyze_innermost): Update after above changes. (create_data_ref): Likewise. * tree-vect-data-refs.c (vect_compute_data_ref_alignment): Likewise. (vect_analyze_data_refs): Likewise. * tree-if-conv.c (if_convertible_loop_p_1): Use memset before creating dummy innermost behavior. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249914 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-data-ref.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gcc/tree-data-ref.h') diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h index c8bb813e77c..45ecf9bc172 100644 --- a/gcc/tree-data-ref.h +++ b/gcc/tree-data-ref.h @@ -52,9 +52,10 @@ struct innermost_loop_behavior tree init; tree step; - /* Alignment information. ALIGNED_TO is set to the largest power of two - that divides OFFSET. */ - tree aligned_to; + /* The largest power of two that divides OFFSET, capped to a suitably + high value if the offset is zero. This is a byte rather than a bit + quantity. */ + unsigned int offset_alignment; }; /* Describes the evolutions of indices of the memory reference. The indices @@ -143,7 +144,7 @@ struct data_reference #define DR_INIT(DR) (DR)->innermost.init #define DR_STEP(DR) (DR)->innermost.step #define DR_PTR_INFO(DR) (DR)->alias.ptr_info -#define DR_ALIGNED_TO(DR) (DR)->innermost.aligned_to +#define DR_OFFSET_ALIGNMENT(DR) (DR)->innermost.offset_alignment #define DR_INNERMOST(DR) (DR)->innermost typedef struct data_reference *data_reference_p; -- cgit v1.2.1 From 668dd7dcb468a4e7114c3c4a301748b491b541c5 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Mon, 3 Jul 2017 13:36:45 +0000 Subject: Add DR_STEP_ALIGNMENT A later patch adds base alignment information to innermost_loop_behavior. After that, the only remaining piece of alignment information that wasn't immediately obvious was the step alignment. Adding that allows a minor simplification to vect_compute_data_ref_alignment, and also potentially improves the handling of variable strides for outer loop vectorisation. A later patch will also use it to give the alignment of the DR as a whole. 2017-07-03 Richard Sandiford gcc/ * tree-data-ref.h (innermost_loop_behavior): Add a step_alignment field. (DR_STEP_ALIGNMENT): New macro. * tree-vectorizer.h (STMT_VINFO_DR_STEP_ALIGNMENT): Likewise. * tree-data-ref.c (dr_analyze_innermost): Initalize step_alignment. (create_data_ref): Print it. * tree-vect-stmts.c (vectorizable_load): Use the step alignment to tell whether the step preserves vector (mis)alignment. * tree-vect-data-refs.c (vect_compute_data_ref_alignment): Likewise. Move the check for an integer step and generalise to all INTEGER_CST. (vect_analyze_data_refs): Set DR_STEP_ALIGNMENT when setting DR_STEP. Print the outer step alignment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249915 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-data-ref.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'gcc/tree-data-ref.h') diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h index 45ecf9bc172..3a5068d3a1f 100644 --- a/gcc/tree-data-ref.h +++ b/gcc/tree-data-ref.h @@ -56,6 +56,9 @@ struct innermost_loop_behavior high value if the offset is zero. This is a byte rather than a bit quantity. */ unsigned int offset_alignment; + + /* Likewise for STEP. */ + unsigned int step_alignment; }; /* Describes the evolutions of indices of the memory reference. The indices @@ -145,6 +148,7 @@ struct data_reference #define DR_STEP(DR) (DR)->innermost.step #define DR_PTR_INFO(DR) (DR)->alias.ptr_info #define DR_OFFSET_ALIGNMENT(DR) (DR)->innermost.offset_alignment +#define DR_STEP_ALIGNMENT(DR) (DR)->innermost.step_alignment #define DR_INNERMOST(DR) (DR)->innermost typedef struct data_reference *data_reference_p; -- cgit v1.2.1 From a5456a6d2e5b85ae2ba6e351ddadf41bacbd6a72 Mon Sep 17 00:00:00 2001 From: rsandifo Date: Mon, 3 Jul 2017 13:36:55 +0000 Subject: Add DR_BASE_ALIGNMENT and DR_BASE_MISALIGNMENT This patch records the base alignment and misalignment in innermost_loop_behavior, to avoid the second-guessing that was previously done in vect_compute_data_ref_alignment. It also makes vect_analyze_data_refs use dr_analyze_innermost, instead of having an almost-copy of the same code. I wasn't sure whether the alignments should be measured in bits (for consistency with most other interfaces) or in bytes (for consistency with DR_ALIGNED_TO, now DR_OFFSET_ALIGNMENT, and with *_ptr_info_alignment). I went for bytes because: - I think in practice most consumers are going to want bytes. E.g. using bytes avoids having to mix TYPE_ALIGN and TYPE_ALIGN_UNIT in vect_compute_data_ref_alignment. - It means that any bit-level paranoia is dealt with when building the innermost_loop_behavior and doesn't get pushed down to consumers. 2017-07-03 Richard Sandiford gcc/ * tree-data-ref.h (innermost_loop_behavior): Add base_alignment and base_misalignment fields. (DR_BASE_ALIGNMENT, DR_BASE_MISALIGNMENT): New macros. * tree-data-ref.c: Include builtins.h. (dr_analyze_innermost): Set up the new innmost_loop_behavior fields. * tree-vectorizer.h (STMT_VINFO_DR_BASE_ALIGNMENT): New macro. (STMT_VINFO_DR_BASE_MISALIGNMENT): Likewise. * tree-vect-data-refs.c: Include tree-cfg.h. (vect_compute_data_ref_alignment): Use the new innermost_loop_behavior fields instead of calculating an alignment here. (vect_analyze_data_refs): Use dr_analyze_innermost. Dump the new innermost_loop_behavior fields. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249916 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-data-ref.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'gcc/tree-data-ref.h') diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h index 3a5068d3a1f..72c68d0fdab 100644 --- a/gcc/tree-data-ref.h +++ b/gcc/tree-data-ref.h @@ -52,6 +52,42 @@ struct innermost_loop_behavior tree init; tree step; + /* BASE_ADDRESS is known to be misaligned by BASE_MISALIGNMENT bytes + from an alignment boundary of BASE_ALIGNMENT bytes. For example, + if we had: + + struct S __attribute__((aligned(16))) { ... }; + + char *ptr; + ... *(struct S *) (ptr - 4) ...; + + the information would be: + + base_address: ptr + base_aligment: 16 + base_misalignment: 4 + init: -4 + + where init cancels the base misalignment. If instead we had a + reference to a particular field: + + struct S __attribute__((aligned(16))) { ... int f; ... }; + + char *ptr; + ... ((struct S *) (ptr - 4))->f ...; + + the information would be: + + base_address: ptr + base_aligment: 16 + base_misalignment: 4 + init: -4 + offsetof (S, f) + + where base_address + init might also be misaligned, and by a different + amount from base_address. */ + unsigned int base_alignment; + unsigned int base_misalignment; + /* The largest power of two that divides OFFSET, capped to a suitably high value if the offset is zero. This is a byte rather than a bit quantity. */ @@ -147,6 +183,8 @@ struct data_reference #define DR_INIT(DR) (DR)->innermost.init #define DR_STEP(DR) (DR)->innermost.step #define DR_PTR_INFO(DR) (DR)->alias.ptr_info +#define DR_BASE_ALIGNMENT(DR) (DR)->innermost.base_alignment +#define DR_BASE_MISALIGNMENT(DR) (DR)->innermost.base_misalignment #define DR_OFFSET_ALIGNMENT(DR) (DR)->innermost.offset_alignment #define DR_STEP_ALIGNMENT(DR) (DR)->innermost.step_alignment #define DR_INNERMOST(DR) (DR)->innermost -- cgit v1.2.1 From 5528b2de4ea96414487dec9b1d8bd76f8729325d Mon Sep 17 00:00:00 2001 From: rsandifo Date: Mon, 3 Jul 2017 13:37:07 +0000 Subject: Add a helper for getting the overall alignment of a DR This combines the information from previous patches to give a guaranteed alignment for the DR as a whole. This should be a bit safer than using base_element_aligned, since that only really took the base into account (not the init or offset). 2017-07-03 Richard Sandiford gcc/ * tree-data-ref.h (dr_alignment): Declare. * tree-data-ref.c (dr_alignment): New function. * tree-vectorizer.h (dataref_aux): Remove base_element_aligned. * tree-vect-data-refs.c (vect_compute_data_ref_alignment): Don't set it. * tree-vect-stmts.c (vectorizable_store): Use dr_alignment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@249917 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/tree-data-ref.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/tree-data-ref.h') diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h index 72c68d0fdab..1559cd90bd2 100644 --- a/gcc/tree-data-ref.h +++ b/gcc/tree-data-ref.h @@ -405,6 +405,16 @@ extern bool compute_all_dependences (vec , vec, bool); extern tree find_data_references_in_bb (struct loop *, basic_block, vec *); +extern unsigned int dr_alignment (innermost_loop_behavior *); + +/* Return the alignment in bytes that DR is guaranteed to have at all + times. */ + +inline unsigned int +dr_alignment (data_reference *dr) +{ + return dr_alignment (&DR_INNERMOST (dr)); +} extern bool dr_may_alias_p (const struct data_reference *, const struct data_reference *, bool); -- cgit v1.2.1