vect: ICE: in vectorizable_load, at tree-vect-stmts.c:9173 [PR94398]
authorFelix Yang <felix.yang@huawei.com>
Tue, 31 Mar 2020 08:41:56 +0000 (16:41 +0800)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 31 Mar 2020 14:13:33 +0000 (15:13 +0100)
In the testcase for PR94398, we're trying to compute:

  alignment_support_scheme
    = vect_supportable_dr_alignment (first_dr_info, false);
  gcc_assert (alignment_support_scheme);

even for VMAT_GATHER_SCATTER, which always accesses individual elements.
Here we should set alignment_support_scheme to dr_unaligned_supported
the gather/scatter case instead of calling vect_supportable_dr_alignment.

2020-03-31  Felix Yang  <felix.yang@huawei.com>

gcc/
PR tree-optimization/94398
* tree-vect-stmts.c (vectorizable_store): Instead of calling
vect_supportable_dr_alignment, set alignment_support_scheme to
dr_unaligned_supported for gather-scatter accesses.
(vectorizable_load): Likewise.

gcc/testsuite/
PR tree-optimization/94398
* gcc.target/aarch64/pr94398.c: New test.

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/pr94398.c [new file with mode: 0644]
gcc/tree-vect-stmts.c

index d79ee54052c7fe0f5832c43371ee8fd13f7a8add..5bd72ccddd9ca792b9eeacc5db7755197ed59131 100644 (file)
@@ -1,3 +1,11 @@
+2020-03-31  Felix Yang  <felix.yang@huawei.com>
+
+       PR tree-optimization/94398
+       * tree-vect-stmts.c (vectorizable_store): Instead of calling
+       vect_supportable_dr_alignment, set alignment_support_scheme to
+       dr_unaligned_supported for gather-scatter accesses.
+       (vectorizable_load): Likewise.
+
 2020-03-31  Andrew Stubbs  <ams@codesourcery.com>
 
        * config/gcn/gcn-valu.md (V_QI, V_HI, V_HF, V_SI, V_SF, V_DI, V_DF):
index 197d87a67af4c96e54ee594f4e807a022be1e52c..1d97d6b52199b80bc5fe8a7518c444c0ccf9643a 100644 (file)
@@ -1,3 +1,8 @@
+2020-03-31  Felix Yang  <felix.yang@huawei.com>
+
+       PR tree-optimization/94398
+       * gcc.target/aarch64/pr94398.c: New test.
+
 2020-03-31  Srinath Parvathaneni  <srinath.parvathaneni@arm.com>
 
        * gcc.target/arm/mve/intrinsics/vbicq_n_s16.c: Modify.
diff --git a/gcc/testsuite/gcc.target/aarch64/pr94398.c b/gcc/testsuite/gcc.target/aarch64/pr94398.c
new file mode 100644 (file)
index 0000000..42152cf
--- /dev/null
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftree-loop-vectorize -funsafe-math-optimizations -march=armv8.2-a+sve -mstrict-align" } */
+
+float
+foo(long n, float *x, int inc_x,
+            float *y, int inc_y)
+{
+  float dot = 0.0;
+  int ix = 0, iy = 0;
+
+  if (n < 0) {
+    return dot;
+  }
+
+  int i = 0;
+  while (i < n) {
+    dot += y[iy] * x[ix];
+    ix  += inc_x;
+    iy  += inc_y;
+    i++;
+  }
+
+  return dot;
+}
index 12beef6978c81d52c65bd85d46ac7a5e556dc92e..46bc2bd067d33997d7ab55430af57ad5d913b683 100644 (file)
@@ -8051,8 +8051,14 @@ vectorizable_store (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
   auto_vec<tree> dr_chain (group_size);
   oprnds.create (group_size);
 
-  alignment_support_scheme
-    = vect_supportable_dr_alignment (first_dr_info, false);
+  /* Gather-scatter accesses perform only component accesses, alignment
+     is irrelevant for them.  */
+  if (memory_access_type == VMAT_GATHER_SCATTER)
+    alignment_support_scheme = dr_unaligned_supported;
+  else
+    alignment_support_scheme
+      = vect_supportable_dr_alignment (first_dr_info, false);
+
   gcc_assert (alignment_support_scheme);
   vec_loop_masks *loop_masks
     = (loop_vinfo && LOOP_VINFO_FULLY_MASKED_P (loop_vinfo)
@@ -9168,8 +9174,14 @@ vectorizable_load (stmt_vec_info stmt_info, gimple_stmt_iterator *gsi,
       ref_type = reference_alias_ptr_type (DR_REF (first_dr_info->dr));
     }
 
-  alignment_support_scheme
-    = vect_supportable_dr_alignment (first_dr_info, false);
+  /* Gather-scatter accesses perform only component accesses, alignment
+     is irrelevant for them.  */
+  if (memory_access_type == VMAT_GATHER_SCATTER)
+    alignment_support_scheme = dr_unaligned_supported;
+  else
+    alignment_support_scheme
+      = vect_supportable_dr_alignment (first_dr_info, false);
+
   gcc_assert (alignment_support_scheme);
   vec_loop_masks *loop_masks
     = (loop_vinfo && LOOP_VINFO_FULLY_MASKED_P (loop_vinfo)