]> git.ipfire.org Git - thirdparty/gcc.git/commit
VECT: Add LEN_FOLD_EXTRACT_LAST pattern
authorJuzhe-Zhong <juzhe.zhong@rivai.ai>
Tue, 22 Aug 2023 10:51:37 +0000 (18:51 +0800)
committerPan Li <pan2.li@intel.com>
Tue, 22 Aug 2023 14:10:25 +0000 (22:10 +0800)
commitf4658e025424ac281dd8b7e61f798f435dbf1cab
tree6df89fa7bf24c43ed51abd0478c0657f0082a76e
parent2c27600fa79431576f47d55b9ed7b2f4790def67
VECT: Add LEN_FOLD_EXTRACT_LAST pattern

Hi, Richard and Richi.

This is the last autovec pattern I want to add for RVV (length loop control).

This patch is supposed to handled this following case:

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

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

  return last;
}

ARM SVE IR:

  ...
  mask__7.11_39 = vect__4.10_37 < vect_cst__38;
  _40 = loop_mask_36 & mask__7.11_39;
  last_5 = .FOLD_EXTRACT_LAST (last_15, _40, vect_vec_iv_.7_32);
  ...

RVV IR, we want to see:
 ...
 loop_len = SELECT_VL
 mask__7.11_39 = vect__4.10_37 < vect_cst__38;
 last_5 = .LEN_FOLD_EXTRACT_LAST (last_15, _40, vect_vec_iv_.7_32, loop_len, bias);
 ...

gcc/ChangeLog:

* doc/md.texi: Add LEN_FOLD_EXTRACT_LAST pattern.
* internal-fn.cc (fold_len_extract_direct): Ditto.
(expand_fold_len_extract_optab_fn): Ditto.
(direct_fold_len_extract_optab_supported_p): Ditto.
* internal-fn.def (LEN_FOLD_EXTRACT_LAST): Ditto.
* optabs.def (OPTAB_D): Ditto.
gcc/doc/md.texi
gcc/internal-fn.cc
gcc/internal-fn.def
gcc/optabs.def