]> git.ipfire.org Git - thirdparty/gcc.git/commit
VECT: Support floating-point in-order reduction for length loop control
authorJu-Zhe Zhong <juzhe.zhong@rivai.ai>
Sun, 23 Jul 2023 04:23:33 +0000 (12:23 +0800)
committerLehua Ding <lehua.ding@rivai.ai>
Mon, 24 Jul 2023 08:22:30 +0000 (16:22 +0800)
commit42b17d00c33dd9994dee973c001d85dc09b79b24
treeadf8a0e1ec69f261df6e55babc49de86f588f726
parent50b5feaa94c26d01fed13f1119f025ae2bc75d2b
VECT: Support floating-point in-order reduction for length loop control

Hi, Richard and Richi.

This patch support floating-point in-order reduction for loop length control.

Consider this following case:

float foo (float *__restrict a, int n)
{
  float result = 1.0;
  for (int i = 0; i < n; i++)
   result += a[i];
  return result;
}

When compile with **NO** -ffast-math on ARM SVE, we will end up with:

loop_mask = WHILE_ULT
result = MASK_FOLD_LEFT_PLUS (...loop_mask...)

For RVV, we don't use length loop control instead of mask:

So, with this patch, we expect to see:

loop_len = SELECT_VL
result = MASK_LEN_FOLD_LEFT_PLUS (...loop_len...)

gcc/ChangeLog:

* tree-vect-loop.cc (get_masked_reduction_fn): Add mask_len_fold_left_plus.
(vectorize_fold_left_reduction): Ditto.
(vectorizable_reduction): Ditto.
(vect_transform_reduction): Ditto.
gcc/tree-vect-loop.cc