aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.cc
diff options
context:
space:
mode:
authorJuzhe-Zhong <juzhe.zhong@rivai.ai>2023-08-24 10:08:36 +0800
committerPan Li <pan2.li@intel.com>2023-08-24 17:02:28 +0800
commita28d4fce8ec2540259a257149de7081f27fb027e (patch)
tree4b51a04be4707ab994c4026e3aacdbd1276f2654 /gcc/tree-vect-loop.cc
parent7b67cab154d4b5ec2a6bb62755da31cefbe63536 (diff)
downloadgcc-a28d4fce8ec2540259a257149de7081f27fb027e.zip
gcc-a28d4fce8ec2540259a257149de7081f27fb027e.tar.gz
gcc-a28d4fce8ec2540259a257149de7081f27fb027e.tar.bz2
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.
Diffstat (limited to 'gcc/tree-vect-loop.cc')
-rw-r--r--gcc/tree-vect-loop.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 1cd6c29..ebee803 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -7494,8 +7494,11 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
}
if (reduc_chain_length == 1
- && direct_internal_fn_supported_p (IFN_FOLD_EXTRACT_LAST,
- vectype_in, OPTIMIZE_FOR_SPEED))
+ && (direct_internal_fn_supported_p (IFN_FOLD_EXTRACT_LAST, vectype_in,
+ OPTIMIZE_FOR_SPEED)
+ || direct_internal_fn_supported_p (IFN_LEN_FOLD_EXTRACT_LAST,
+ vectype_in,
+ OPTIMIZE_FOR_SPEED)))
{
if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,