]> git.ipfire.org Git - thirdparty/gcc.git/commit
VECT: Apply LEN_FOLD_EXTRACT_LAST into loop vectorizer
authorJuzhe-Zhong <juzhe.zhong@rivai.ai>
Thu, 24 Aug 2023 02:08:36 +0000 (10:08 +0800)
committerPan Li <pan2.li@intel.com>
Thu, 24 Aug 2023 09:02:28 +0000 (17:02 +0800)
commita28d4fce8ec2540259a257149de7081f27fb027e
tree4b51a04be4707ab994c4026e3aacdbd1276f2654
parent7b67cab154d4b5ec2a6bb62755da31cefbe63536
VECT: Apply LEN_FOLD_EXTRACT_LAST into loop vectorizer

Hi.

This patch is apply LEN_FOLD_EXTRACT_LAST into loop vectorizer.

Consider this following case:

/* Simple condition reduction.  */

int __attribute__ ((noinline, noclone))
condition_reduction (int *a, int min_v)
{
  int last = 66; /* High start value.  */

  for (int i = 0; i < N; i++)
    if (a[i] < min_v)
      last = i;

  return last;
}

With this patch, we can generate this following IR:

  _44 = .SELECT_VL (ivtmp_42, POLY_INT_CST [4, 4]);
  _34 = vect_vec_iv_.5_33 + { POLY_INT_CST [4, 4], ... };
  ivtmp_36 = _44 * 4;
  vect__4.8_39 = .MASK_LEN_LOAD (vectp_a.6_37, 32B, { -1, ... }, _44, 0);

  mask__11.9_41 = vect__4.8_39 < vect_cst__40;
  last_5 = .LEN_FOLD_EXTRACT_LAST (last_14, mask__11.9_41, vect_vec_iv_.5_33, _44, 0);
  ...

gcc/ChangeLog:

* tree-vect-loop.cc (vectorizable_reduction): Apply
LEN_FOLD_EXTRACT_LAST.
* tree-vect-stmts.cc (vectorizable_condition): Ditto.
gcc/tree-vect-loop.cc
gcc/tree-vect-stmts.cc