aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-11-25 09:46:28 +0100
committerRichard Biener <rguenth@gcc.gnu.org>2024-11-25 10:50:23 +0100
commit0b47d7579e84daa4dfa16baef1133ab73adc502d (patch)
tree051b39d9356c0c8848c3520572a869982f8271a9 /gcc
parente984ba40aa0c1fa3460e0266deb59b9036ba8454 (diff)
downloadgcc-0b47d7579e84daa4dfa16baef1133ab73adc502d.zip
gcc-0b47d7579e84daa4dfa16baef1133ab73adc502d.tar.gz
gcc-0b47d7579e84daa4dfa16baef1133ab73adc502d.tar.bz2
tree-optimization/117767 - VMAT_STRIDED_SLP and alignment
This plugs another hole in alignment checking with VMAT_STRIDED_SLP. When using an alternate load or store type we have to check whether that's supported with respect to required vector alignment. PR tree-optimization/117767 * tree-vect-stmts.cc (vectorizable_store): Check for supported alignment before using a an alternate store vector type. (vectorizable_load): Likewise for loads. * gcc.dg/vect/pr117767.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr117767.c17
-rw-r--r--gcc/tree-vect-stmts.cc44
2 files changed, 55 insertions, 6 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/pr117767.c b/gcc/testsuite/gcc.dg/vect/pr117767.c
new file mode 100644
index 0000000..a0ed178
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr117767.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+struct bbro_basic_block_data {
+ int priority;
+ void *heap;
+ void *node;
+};
+int array_size;
+struct bbro_basic_block_data *bbd;
+void reorder_basic_blocks_software_trace_cache(void)
+{
+ int i;
+ for (i = 0; i < array_size; i++) {
+ bbd[i].heap = (void *)0;
+ bbd[i].node = (void *)0;
+ }
+}
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 17c05fb..82cd389 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -8693,6 +8693,12 @@ vectorizable_store (vec_info *vinfo,
lnel = n;
ltype = build_vector_type (elem_type, n);
lvectype = vectype;
+ int mis_align = dr_misalignment (first_dr_info, ltype);
+ dr_alignment_support dr_align
+ = vect_supportable_dr_alignment (vinfo, dr_info, ltype,
+ mis_align);
+ alignment_support_scheme = dr_align;
+ misalignment = mis_align;
/* First check if vec_extract optab doesn't support extraction
of vector elts directly. */
@@ -8703,7 +8709,9 @@ vectorizable_store (vec_info *vinfo,
n).exists (&vmode)
|| (convert_optab_handler (vec_extract_optab,
TYPE_MODE (vectype), vmode)
- == CODE_FOR_nothing))
+ == CODE_FOR_nothing)
+ || !(dr_align == dr_aligned
+ || dr_align == dr_unaligned_supported))
{
/* Try to avoid emitting an extract of vector elements
by performing the extracts using an integer type of the
@@ -8733,7 +8741,16 @@ vectorizable_store (vec_info *vinfo,
Fewer stores are more important than avoiding spilling
of the vector we extract from. Compared to the
construction case in vectorizable_load no store-forwarding
- issue exists here for reasonable archs. */
+ issue exists here for reasonable archs. But only
+ if the store is supported. */
+ else if (!(dr_align == dr_aligned
+ || dr_align == dr_unaligned_supported))
+ {
+ nstores = const_nunits;
+ lnel = 1;
+ ltype = elem_type;
+ lvectype = vectype;
+ }
}
}
ltype = build_aligned_type (ltype, TYPE_ALIGN (elem_type));
@@ -10680,10 +10697,25 @@ vectorizable_load (vec_info *vinfo,
&ptype);
if (vtype != NULL_TREE)
{
- nloads = const_nunits / n;
- lnel = n;
- lvectype = vtype;
- ltype = ptype;
+ dr_alignment_support dr_align = dr_aligned;
+ int mis_align = 0;
+ if (VECTOR_TYPE_P (ptype))
+ {
+ mis_align = dr_misalignment (first_dr_info, ptype);
+ dr_align
+ = vect_supportable_dr_alignment (vinfo, dr_info, ptype,
+ mis_align);
+ }
+ if (dr_align == dr_aligned
+ || dr_align == dr_unaligned_supported)
+ {
+ nloads = const_nunits / n;
+ lnel = n;
+ lvectype = vtype;
+ ltype = ptype;
+ alignment_support_scheme = dr_align;
+ misalignment = mis_align;
+ }
}
}
/* Else fall back to the default element-wise access. */