On Thu, 22 Oct 2026, Konstantinos Eleftheriou wrote:

> A loop that reads and writes through two pointers that may alias is
> versioned on a runtime alias check. The IFN and WAR/WAW checks accept
> equal pointers, but many pairs get the address-based overlap test
> instead: a pair with a reordered member, a merged pair whose members
> access the two pointers in opposite orders, or a RAW pair that the
> target's IFN pattern cannot handle. The overlap test fails when the
> pointers are equal, so a loop called with its output equal to its input
> runs the scalar version. This affects SPEC2026's 736.ocio_r benchmark,
> whose renderers process a single buffer in place.
> 
> This patch makes the overlap test accept equal pointers for the pairs
> where that is safe. A pair qualifies when its two accesses have the same
> size and lie on a common grid of that size, meaning that their common
> stride and the distance between them are multiples of the size. They
> must also either never coincide, or coincide only in the same iteration
> and stay in scalar order when vectorized. Other pairs, such as a read
> one element ahead of a store or accesses of different sizes, can overlap
> across iterations or partially, so they keep the original test.
> 
> The check is done per member pair in vect_prune_runtime_alias_test_list,
> before the group leaders are substituted and the pairs are merged, and
> its result is carried in a new inplace_safe field. A merged pair
> qualifies only if all its members do. For a qualifying pair,
> create_intersect_range_checks ORs a base-address equality into the
> overlap test.
> 
> This speeds up 736.ocio_r by 4.3% on AArch64.
> 
> Tested on aarch64-linux-gnu and x86_64-linux-gnu.

Sashiko points out 
https://gcc.sashiko.dev/#/patchset/20261023064455.3443954-1-konstantinos.eleftheriou%40vrull.eu

and I wonder why you add a bool when 'flags' has loads of bits left.

Richard.


> gcc/ChangeLog:
> 
>       * tree-data-ref.cc (merge_alias_pair_into): New function.
>       (prune_runtime_alias_test_list): Use it at both merge sites.
>       (relax_cond_for_inplace_aliasing): New function.
>       (create_intersect_range_checks): Use it on the address-based
>       overlap path only.
>       * tree-data-ref.h (dr_with_seg_len_pair_t): Add inplace_safe.
>       * tree-vect-data-refs.cc (vect_inplace_alias_result): New function.
>       (vect_inplace_alias_safe_p): Likewise.
>       (vect_prune_runtime_alias_test_list): Call it on each member
>       pair before substituting the group leaders.
> 
> gcc/testsuite/ChangeLog:
> 
>       * gcc.dg/vect/vect-alias-check-inplace-run.c: New test.
>       * gcc.target/aarch64/vect-alias-check-inplace.c: New test.
> 
> Co-authored-by: Philipp Tomsich <[email protected]>
> ---
>  .../vect/vect-alias-check-inplace-run.c       | 309 ++++++++++++++++++
>  .../aarch64/vect-alias-check-inplace.c        |  30 ++
>  gcc/tree-data-ref.cc                          |  44 ++-
>  gcc/tree-data-ref.h                           |   6 +-
>  gcc/tree-vect-data-refs.cc                    |  88 +++++
>  5 files changed, 474 insertions(+), 3 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.dg/vect/vect-alias-check-inplace-run.c
>  create mode 100644 
> gcc/testsuite/gcc.target/aarch64/vect-alias-check-inplace.c
> 
> diff --git a/gcc/testsuite/gcc.dg/vect/vect-alias-check-inplace-run.c 
> b/gcc/testsuite/gcc.dg/vect/vect-alias-check-inplace-run.c
> new file mode 100644
> index 000000000000..2b9b235da230
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/vect/vect-alias-check-inplace-run.c
> @@ -0,0 +1,309 @@
> +/* Each kernel is called with the output aliasing the input and compared
> +   against a scalar reference.  */
> +
> +#include "tree-vect.h"
> +
> +#define N 64
> +
> +__attribute__ ((noipa)) float
> +read_ahead (float *x, float *y, int n)
> +{
> +  float s = 0.0f;
> +  for (int i = 0; i < n; i++)
> +    {
> +      x[i] = (float) i;
> +      s += y[i] + y[i + 1];
> +    }
> +  return s;
> +}
> +
> +__attribute__ ((noipa)) float
> +store_after_load (float *x, float *y, int n)
> +{
> +  float s = 0.0f;
> +  for (int i = 0; i < n; i++)
> +    {
> +      x[2 * i] = (float) i;
> +      s += y[2 * i] + y[2 * i + 1];
> +      x[2 * i + 1] = 2.0f;
> +    }
> +  return s;
> +}
> +
> +__attribute__ ((noipa)) float
> +read_ahead_ref (float *x, float *y, int n)
> +{
> +  float s = 0.0f;
> +#pragma GCC novector
> +  for (int i = 0; i < n; i++)
> +    {
> +      x[i] = (float) i;
> +      s += y[i] + y[i + 1];
> +    }
> +  return s;
> +}
> +
> +__attribute__ ((noipa)) float
> +store_after_load_ref (float *x, float *y, int n)
> +{
> +  float s = 0.0f;
> +#pragma GCC novector
> +  for (int i = 0; i < n; i++)
> +    {
> +      x[2 * i] = (float) i;
> +      s += y[2 * i] + y[2 * i + 1];
> +      x[2 * i + 1] = 2.0f;
> +    }
> +  return s;
> +}
> +
> +/* Offsets two bytes apart are off the four-byte grid, so each load
> +   partially overlaps the store of its own iteration and of the next one.  */
> +
> +__attribute__ ((noipa)) unsigned
> +off_grid_cross (unsigned char *x, unsigned char *y, int n)
> +{
> +  unsigned s = 0;
> +  for (int i = 0; i < n; i++)
> +    {
> +      unsigned v = i * 0x01010101u;
> +      __builtin_memcpy (x + 4 * i + 2, &v, 4);
> +      unsigned t;
> +      __builtin_memcpy (&t, y + 4 * i + 4, 4);
> +      s += t;
> +    }
> +  return s;
> +}
> +
> +/* Accesses of different sizes, the smaller first, so that only the size
> +   check refuses the pair.  The next iteration's short store overlaps this
> +   iteration's int load.  */
> +
> +__attribute__ ((noipa)) unsigned
> +mixed_size_cross (unsigned char *x, unsigned char *y, int n)
> +{
> +  unsigned s = 0;
> +  for (int i = 0; i < n; i++)
> +    {
> +      unsigned short v = i * 3u;
> +      __builtin_memcpy (x + 8 * i + 6, &v, 2);
> +      unsigned t;
> +      __builtin_memcpy (&t, y + 8 * i + 12, 4);
> +      s += t;
> +    }
> +  return s;
> +}
> +
> +__attribute__ ((noipa)) unsigned
> +off_grid_cross_ref (unsigned char *x, unsigned char *y, int n)
> +{
> +  unsigned s = 0;
> +#pragma GCC novector
> +  for (int i = 0; i < n; i++)
> +    {
> +      unsigned v = i * 0x01010101u;
> +      __builtin_memcpy (x + 4 * i + 2, &v, 4);
> +      unsigned t;
> +      __builtin_memcpy (&t, y + 4 * i + 4, 4);
> +      s += t;
> +    }
> +  return s;
> +}
> +
> +__attribute__ ((noipa)) unsigned
> +mixed_size_cross_ref (unsigned char *x, unsigned char *y, int n)
> +{
> +  unsigned s = 0;
> +#pragma GCC novector
> +  for (int i = 0; i < n; i++)
> +    {
> +      unsigned short v = i * 3u;
> +      __builtin_memcpy (x + 8 * i + 6, &v, 2);
> +      unsigned t;
> +      __builtin_memcpy (&t, y + 8 * i + 12, 4);
> +      s += t;
> +    }
> +  return s;
> +}
> +
> +/* Relaxed for an exact in-place call.  A partial overlap must still take
> +   the scalar version.  */
> +
> +__attribute__ ((noipa)) void
> +scale4 (float *out, const float *in, int n)
> +{
> +  for (int i = 0; i < n; i++, out += 4, in += 4)
> +    {
> +      out[0] = in[0] * 2.0f;
> +      out[1] = in[1] * 3.0f;
> +      out[2] = in[2] * 4.0f;
> +      out[3] = in[3] * 5.0f;
> +    }
> +}
> +
> +__attribute__ ((noipa)) void
> +scale4_ref (float *out, const float *in, int n)
> +{
> +#pragma GCC novector
> +  for (int i = 0; i < n; i++, out += 4, in += 4)
> +    {
> +      out[0] = in[0] * 2.0f;
> +      out[1] = in[1] * 3.0f;
> +      out[2] = in[2] * 4.0f;
> +      out[3] = in[3] * 5.0f;
> +    }
> +}
> +
> +/* The same kernel walked backwards, for a negative step.  */
> +
> +__attribute__ ((noipa)) void
> +scale4_down (float *out, const float *in, int n)
> +{
> +  out += 4 * (n - 1);
> +  in += 4 * (n - 1);
> +  for (int i = 0; i < n; i++, out -= 4, in -= 4)
> +    {
> +      out[0] = in[0] * 2.0f;
> +      out[1] = in[1] * 3.0f;
> +      out[2] = in[2] * 4.0f;
> +      out[3] = in[3] * 5.0f;
> +    }
> +}
> +
> +__attribute__ ((noipa)) void
> +scale4_down_ref (float *out, const float *in, int n)
> +{
> +  out += 4 * (n - 1);
> +  in += 4 * (n - 1);
> +#pragma GCC novector
> +  for (int i = 0; i < n; i++, out -= 4, in -= 4)
> +    {
> +      out[0] = in[0] * 2.0f;
> +      out[1] = in[1] * 3.0f;
> +      out[2] = in[2] * 4.0f;
> +      out[3] = in[3] * 5.0f;
> +    }
> +}
> +
> +/* Byte channels fit several iterations into one vector, which the float
> +   kernels above do not on most targets.  */
> +
> +__attribute__ ((noipa)) void
> +add4 (unsigned char *out, const unsigned char *in, int n)
> +{
> +  for (int i = 0; i < n; i++, out += 4, in += 4)
> +    {
> +      out[0] = in[0] + 1;
> +      out[1] = in[1] + 2;
> +      out[2] = in[2] + 3;
> +      out[3] = in[3] + 4;
> +    }
> +}
> +
> +__attribute__ ((noipa)) void
> +add4_ref (unsigned char *out, const unsigned char *in, int n)
> +{
> +#pragma GCC novector
> +  for (int i = 0; i < n; i++, out += 4, in += 4)
> +    {
> +      out[0] = in[0] + 1;
> +      out[1] = in[1] + 2;
> +      out[2] = in[2] + 3;
> +      out[3] = in[3] + 4;
> +    }
> +}
> +
> +static float f[4 * N + 2], fref[4 * N + 2];
> +static unsigned char c[8 * N + 16], cref[8 * N + 16];
> +
> +/* Give each buffer and its reference copy the same contents.  */
> +
> +static void
> +reset (void)
> +{
> +  for (int i = 0; i < 4 * N + 2; i++)
> +    f[i] = fref[i] = 1.0f + i;
> +  for (int i = 0; i < 8 * N + 16; i++)
> +    c[i] = cref[i] = i;
> +}
> +
> +/* Abort unless each buffer matches its reference copy.  */
> +
> +static void
> +check (void)
> +{
> +  if (__builtin_memcmp (f, fref, sizeof f) != 0
> +      || __builtin_memcmp (c, cref, sizeof c) != 0)
> +    __builtin_abort ();
> +}
> +
> +int
> +main (void)
> +{
> +  check_vect ();
> +
> +  reset ();
> +  if (read_ahead (f, f, N) != read_ahead_ref (fref, fref, N))
> +    __builtin_abort ();
> +  check ();
> +
> +  reset ();
> +  if (store_after_load (f, f, N) != store_after_load_ref (fref, fref, N))
> +    __builtin_abort ();
> +  check ();
> +
> +  /* Exactly in place.  The relaxation applies, and the result must match
> +     the reference.  */
> +  reset ();
> +  scale4 (f, f, N);
> +  scale4_ref (fref, fref, N);
> +  check ();
> +
> +  /* Partial overlap off the grid, across iterations.  */
> +  reset ();
> +  if (off_grid_cross (c, c, N) != off_grid_cross_ref (cref, cref, N))
> +    __builtin_abort ();
> +  check ();
> +
> +  /* The same with mismatched access sizes.  */
> +  reset ();
> +  if (mixed_size_cross (c, c, N) != mixed_size_cross_ref (cref, cref, N))
> +    __builtin_abort ();
> +  check ();
> +
> +  /* Negative step, exactly in place.  */
> +  reset ();
> +  scale4_down (f, f, N);
> +  scale4_down_ref (fref, fref, N);
> +  check ();
> +
> +  /* Output one element ahead of the input.  The equality term is false,
> +     so the scalar version must run.  */
> +  reset ();
> +  scale4 (f + 1, f, N - 1);
> +  scale4_ref (fref + 1, fref, N - 1);
> +  check ();
> +
> +  /* The byte kernel, exactly in place.  */
> +  reset ();
> +  add4 (c, c, N);
> +  add4_ref (cref, cref, N);
> +  check ();
> +
> +  /* The byte kernel with the output one byte ahead of the input.  */
> +  reset ();
> +  add4 (c + 1, c, N);
> +  add4_ref (cref + 1, cref, N);
> +  check ();
> +
> +  return 0;
> +}
> +
> +/* scale4, scale4_down and add4 are relaxed, and every other kernel is
> +   refused.  The memcpy kernels reach the check only where the memcpy folds
> +   to a MEM_REF, hence non_strict_align.  */
> +/* { dg-final { scan-tree-dump-times "relaxed to permit exact in-place 
> aliasing" 3 "vect" { target { vect_float && vect_int } } } } */
> +/* { dg-final { scan-tree-dump "dependence across iterations" "vect" { 
> target vect_float } } } */
> +/* { dg-final { scan-tree-dump "dependence distance 0, reordered" "vect" { 
> target vect_float } } } */
> +/* { dg-final { scan-tree-dump "unsigned int> \[^\n\]* and MEM <unsigned 
> int> \[^\n\]*may overlap partially" "vect" { target { vect_int && 
> non_strict_align } } } } */
> +/* { dg-final { scan-tree-dump "unsigned short> \[^\n\]*may overlap 
> partially" "vect" { target { vect_int && non_strict_align } } } } */
> diff --git a/gcc/testsuite/gcc.target/aarch64/vect-alias-check-inplace.c 
> b/gcc/testsuite/gcc.target/aarch64/vect-alias-check-inplace.c
> new file mode 100644
> index 000000000000..1bd1e8d44663
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/vect-alias-check-inplace.c
> @@ -0,0 +1,30 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -ftree-vectorize -march=armv8-a 
> -fdump-tree-vect-details" } */
> +
> +/* A RAW pair on plain Advanced SIMD reaches the address-based overlap
> +   test, which is false for x == y and so needs the relaxation.  */
> +
> +float
> +fn (float *x, float *y, int n)
> +{
> +  float s = 0.0f;
> +  for (int i = 0; i < n; i++)
> +    {
> +      x[i] = (float) i;
> +      s += y[i];
> +    }
> +  return s;
> +}
> +
> +/* A WAR pair gets an ordering test, which admits distance zero already.
> +   The count below asserts it does not pick up the equality term.  */
> +
> +void
> +fn_war (float *x, const float *y, int n)
> +{
> +  for (int i = 0; i < n; i++)
> +    x[i] = y[i] * 2.0f;
> +}
> +
> +/* { dg-final { scan-tree-dump "using an address-based WAR/WAW test" "vect" 
> } } */
> +/* { dg-final { scan-tree-dump-times "relaxed to permit exact in-place 
> aliasing" 1 "vect" } } */
> diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc
> index 400a405792bb..b22e17a1a302 100644
> --- a/gcc/tree-data-ref.cc
> +++ b/gcc/tree-data-ref.cc
> @@ -1831,6 +1831,20 @@ dump_alias_pair (dr_with_seg_len_pair_t *alias_pair, 
> const char *indent)
>    if (alias_pair->flags == 0)
>      dump_printf (MSG_NOTE, " <none>");
>    dump_printf (MSG_NOTE, "\n");
> +  if (alias_pair->inplace_safe)
> +    dump_printf (MSG_NOTE, "%sin-place:       safe\n", indent);
> +}
> +
> +/* Fold the pair SRC into DST as part of a merge: the dependence and
> +   ordering flags accumulate, and DST stays safe for in-place aliasing only
> +   if both pairs were.  */
> +
> +static void
> +merge_alias_pair_into (dr_with_seg_len_pair_t *dst,
> +                    const dr_with_seg_len_pair_t *src)
> +{
> +  dst->flags |= src->flags;
> +  dst->inplace_safe &= src->inplace_safe;
>  }
>  
>  /* Merge alias checks recorded in ALIAS_PAIRS and remove redundant ones.
> @@ -1919,7 +1933,7 @@ prune_runtime_alias_test_list 
> (vec<dr_with_seg_len_pair_t> *alias_pairs,
>           dump_printf (MSG_NOTE, "found equal ranges %T, %T and %T, %T\n",
>                        DR_REF (dr_a1->dr), DR_REF (dr_b1->dr),
>                        DR_REF (dr_a2->dr), DR_REF (dr_b2->dr));
> -       alias_pair1->flags |= alias_pair2->flags;
> +       merge_alias_pair_into (alias_pair1, alias_pair2);
>         continue;
>       }
>  
> @@ -2035,7 +2049,7 @@ prune_runtime_alias_test_list 
> (vec<dr_with_seg_len_pair_t> *alias_pairs,
>           dump_printf (MSG_NOTE, "merging ranges for %T, %T and %T, %T\n",
>                        DR_REF (dr_a1->dr), DR_REF (dr_b1->dr),
>                        DR_REF (dr_a2->dr), DR_REF (dr_b2->dr));
> -       alias_pair1->flags |= alias_pair2->flags;
> +       merge_alias_pair_into (alias_pair1, alias_pair2);
>         last -= 1;
>       }
>      }
> @@ -2135,6 +2149,31 @@ create_ifn_alias_checks (tree *cond_expr,
>    return true;
>  }
>  
> +/* Extend *COND_EXPR, the overlap test for ALIAS_PAIR, to also accept equal
> +   base addresses, so that an in-place call takes the vector version.  The
> +   IFN and WAR/WAW checks already accept equal addresses, and on SVE2 an
> +   equality term would stop the whilerw result from feeding the branch
> +   directly.  */
> +
> +static void
> +relax_cond_for_inplace_aliasing (tree *cond_expr,
> +                              const dr_with_seg_len_pair_t &alias_pair)
> +{
> +  if (*cond_expr == boolean_true_node || !alias_pair.inplace_safe)
> +    return;
> +
> +  tree ba = DR_BASE_ADDRESS (alias_pair.first.dr);
> +  tree bb = DR_BASE_ADDRESS (alias_pair.second.dr);
> +  /* Compare as pointers, like the overlap test itself, which builds its
> +     bounds from these same two bases.  */
> +  tree base_eq = fold_build2 (EQ_EXPR, boolean_type_node, ba,
> +                           fold_convert (TREE_TYPE (ba), bb));
> +  *cond_expr = fold_build2 (TRUTH_OR_EXPR, boolean_type_node,
> +                         base_eq, *cond_expr);
> +  if (dump_enabled_p ())
> +    dump_printf (MSG_NOTE, "relaxed to permit exact in-place aliasing\n");
> +}
> +
>  /* Try to generate a runtime condition that is true if ALIAS_PAIR is
>     free of aliases, using a condition based on index values instead
>     of a condition based on addresses.  Return true on success,
> @@ -2720,6 +2759,7 @@ create_intersect_range_checks (class loop *loop, tree 
> *cond_expr,
>       fold_build2 (cmp_code, boolean_type_node, seg_b_max, seg_a_min));
>    if (dump_enabled_p ())
>      dump_printf (MSG_NOTE, "using an address-based overlap test\n");
> +  relax_cond_for_inplace_aliasing (cond_expr, alias_pair);
>  }
>  
>  /* Create a conditional expression that represents the run-time checks for
> diff --git a/gcc/tree-data-ref.h b/gcc/tree-data-ref.h
> index ba901a5f6cee..af09d13d3960 100644
> --- a/gcc/tree-data-ref.h
> +++ b/gcc/tree-data-ref.h
> @@ -321,12 +321,16 @@ public:
>    dr_with_seg_len first;
>    dr_with_seg_len second;
>    unsigned int flags;
> +  /* True if the new code stays correct for every access pair being checked
> +     when the two base addresses are equal, so that an overlap test can
> +     accept that case too.  */
> +  bool inplace_safe;
>  };
>  
>  inline dr_with_seg_len_pair_t::
>  dr_with_seg_len_pair_t (const dr_with_seg_len &d1, const dr_with_seg_len &d2,
>                       sequencing seq)
> -  : first (d1), second (d2), flags (0)
> +  : first (d1), second (d2), flags (0), inplace_safe (false)
>  {
>    if (DR_IS_READ (d1.dr) && DR_IS_WRITE (d2.dr))
>      flags |= DR_ALIAS_WAR;
> diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
> index 22fce2c927b3..46455e6102f9 100644
> --- a/gcc/tree-vect-data-refs.cc
> +++ b/gcc/tree-vect-data-refs.cc
> @@ -4076,6 +4076,87 @@ vectorizable_with_step_bound_p (dr_vec_info 
> *dr_info_a, dr_vec_info *dr_info_b,
>    return true;
>  }
>  
> +/* Dump whether the in-place check found DR_INFO_A and DR_INFO_B safe, and
> +   REASON, then return SAFE.  */
> +
> +static bool
> +vect_inplace_alias_result (dr_vec_info *dr_info_a, dr_vec_info *dr_info_b,
> +                        bool safe, const char *reason)
> +{
> +  if (dump_enabled_p ())
> +    dump_printf_loc (MSG_NOTE, vect_location,
> +                  "in-place aliasing %s for %T and %T (%s)\n",
> +                  safe ? "safe" : "unsafe", DR_REF (dr_info_a->dr),
> +                  DR_REF (dr_info_b->dr), reason);
> +
> +  return safe;
> +}
> +
> +/* Return true if accesses DR_INFO_A and DR_INFO_B, which need a runtime
> +   alias check, stay correct when their base addresses are equal.
> +   PRESERVES_SCALAR_ORDER_P says whether vectorization keeps the two in
> +   scalar order.
> +
> +   The two must have the same size and lie on a common grid of that size.
> +   That is, the step and the distance between them are multiples of the
> +   size, so that any two of their accesses cover the same bytes or none.
> +   Other pairs could overlap partially and are refused.  Pairs on a common
> +   grid are safe if they never access the same element, or access it in
> +   the same iteration and stay in scalar order.  */
> +
> +static bool
> +vect_inplace_alias_safe_p (dr_vec_info *dr_info_a, dr_vec_info *dr_info_b,
> +                        bool preserves_scalar_order_p)
> +{
> +  data_reference *dr_a = dr_info_a->dr;
> +  data_reference *dr_b = dr_info_b->dr;
> +  if (!tree_fits_shwi_p (DR_STEP (dr_a))
> +      || !tree_fits_shwi_p (DR_STEP (dr_b))
> +      || !tree_fits_shwi_p (DR_INIT (dr_a))
> +      || !tree_fits_shwi_p (DR_INIT (dr_b)))
> +    return vect_inplace_alias_result (dr_info_a, dr_info_b, false,
> +                                   "non-constant step or init");
> +
> +  HOST_WIDE_INT step = tree_to_shwi (DR_STEP (dr_a));
> +  if (step != tree_to_shwi (DR_STEP (dr_b)) || step == 0)
> +    return vect_inplace_alias_result (dr_info_a, dr_info_b, false,
> +                                   "different or zero steps");
> +
> +  if (!operand_equal_p (DR_OFFSET (dr_a), DR_OFFSET (dr_b), 0))
> +    return vect_inplace_alias_result (dr_info_a, dr_info_b, false,
> +                                   "different offsets");
> +
> +  tree size_a = TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr_a)));
> +  tree size_b = TYPE_SIZE_UNIT (TREE_TYPE (DR_REF (dr_b)));
> +  /* The difference of the two inits can overflow a HOST_WIDE_INT.  */
> +  offset_int init_distance
> +    = wi::to_offset (DR_INIT (dr_a)) - wi::to_offset (DR_INIT (dr_b));
> +  if (!tree_fits_shwi_p (size_a)
> +      || !tree_int_cst_equal (size_a, size_b)
> +      || tree_to_shwi (size_a) == 0
> +      || step % tree_to_shwi (size_a) != 0
> +      || init_distance % tree_to_shwi (size_a) != 0)
> +    return vect_inplace_alias_result (dr_info_a, dr_info_b, false,
> +                                   "accesses may overlap partially");
> +
> +  if (init_distance == 0)
> +    {
> +      if (!preserves_scalar_order_p)
> +     return vect_inplace_alias_result (dr_info_a, dr_info_b, false,
> +                                       "dependence distance 0, reordered");
> +
> +      return vect_inplace_alias_result (dr_info_a, dr_info_b, true,
> +                                     "dependence distance 0, order kept");
> +    }
> +
> +  if (init_distance % step == 0)
> +    return vect_inplace_alias_result (dr_info_a, dr_info_b, false,
> +                                   "dependence across iterations");
> +
> +  return vect_inplace_alias_result (dr_info_a, dr_info_b, true,
> +                                 "no dependence");
> +}
> +
>  /* Function vect_prune_runtime_alias_test_list.
>  
>     Prune a list of ddrs to be tested at run-time by versioning for alias.
> @@ -4217,6 +4298,12 @@ vect_prune_runtime_alias_test_list (loop_vec_info 
> loop_vinfo)
>         continue;
>       }
>  
> +      /* The in-place check needs the individual accesses, so do it before
> +      DR_INFO_A and DR_INFO_B are replaced by their group leaders.  */
> +      bool inplace_safe
> +     = vect_inplace_alias_safe_p (dr_info_a, dr_info_b,
> +                                  preserves_scalar_order_p);
> +
>        stmt_vec_info dr_group_first_a = DR_GROUP_FIRST_ELEMENT (stmt_info_a);
>        if (dr_group_first_a)
>       {
> @@ -4316,6 +4403,7 @@ vect_prune_runtime_alias_test_list (loop_vec_info 
> loop_vinfo)
>       (dr_a, dr_b, (preserves_scalar_order_p
>                     ? dr_with_seg_len_pair_t::WELL_ORDERED
>                     : dr_with_seg_len_pair_t::REORDERED));
> +      dr_with_seg_len_pair.inplace_safe = inplace_safe;
>  
>        comp_alias_ddrs.safe_push (dr_with_seg_len_pair);
>      }
> 

-- 
Richard Biener <[email protected]>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg)

Reply via email to