aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-vect-loop.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2019-10-25 08:22:13 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2019-10-25 08:22:13 +0000
commit89d0345ad7b8d84045813972ee60557a6b511c57 (patch)
tree679d68b4d491389b86c0d17c7a69516757266ecd /gcc/tree-vect-loop.c
parentea133b14f48ed5730748a7e02e322fb07ccc2d85 (diff)
downloadgcc-89d0345ad7b8d84045813972ee60557a6b511c57.zip
gcc-89d0345ad7b8d84045813972ee60557a6b511c57.tar.gz
gcc-89d0345ad7b8d84045813972ee60557a6b511c57.tar.bz2
Fix reductions for fully-masked loops
Now that vectorizable_operation vectorises most loop stmts involved in a reduction, it needs to be aware of reductions in fully-masked loops. The LOOP_VINFO_CAN_FULLY_MASK_P parts of vectorizable_reduction now only apply to cases that use vect_transform_reduction. This new way of doing things is definitely an improvement for SVE though, since it means we can lift the old restriction of not using fully-masked loops for reduction chains. 2019-10-25 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-loop.c (vectorizable_reduction): Restrict the LOOP_VINFO_CAN_FULLY_MASK_P handling to cases that will be handled by vect_transform_reduction. Allow fully-masked loops to be used with reduction chains. * tree-vect-stmts.c (vectorizable_operation): Handle reduction operations in fully-masked loops. (vectorizable_condition): Reject EXTRACT_LAST_REDUCTION operations in fully-masked loops. gcc/testsuite/ * gcc.dg/vect/pr65947-1.c: No longer expect doubled dump lines for FOLD_EXTRACT_LAST reductions. * gcc.dg/vect/pr65947-2.c: Likewise. * gcc.dg/vect/pr65947-3.c: Likewise. * gcc.dg/vect/pr65947-4.c: Likewise. * gcc.dg/vect/pr65947-5.c: Likewise. * gcc.dg/vect/pr65947-6.c: Likewise. * gcc.dg/vect/pr65947-9.c: Likewise. * gcc.dg/vect/pr65947-10.c: Likewise. * gcc.dg/vect/pr65947-12.c: Likewise. * gcc.dg/vect/pr65947-13.c: Likewise. * gcc.dg/vect/pr65947-14.c: Likewise. * gcc.dg/vect/pr80631-1.c: Likewise. * gcc.dg/vect/pr80631-2.c: Likewise. * gcc.dg/vect/vect-cond-reduc-3.c: Likewise. * gcc.dg/vect/vect-cond-reduc-4.c: Likewise. From-SVN: r277438
Diffstat (limited to 'gcc/tree-vect-loop.c')
-rw-r--r--gcc/tree-vect-loop.c51
1 files changed, 21 insertions, 30 deletions
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index d0fd7bdb..3b58cee 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -6319,38 +6319,8 @@ vectorizable_reduction (stmt_vec_info stmt_info, slp_tree slp_node,
else
vec_num = 1;
- internal_fn cond_fn = get_conditional_internal_fn (code);
- vec_loop_masks *masks = &LOOP_VINFO_MASKS (loop_vinfo);
- bool mask_by_cond_expr = use_mask_by_cond_expr_p (code, cond_fn, vectype_in);
-
vect_model_reduction_cost (stmt_info, reduc_fn, reduction_type, ncopies,
cost_vec);
- if (loop_vinfo && LOOP_VINFO_CAN_FULLY_MASK_P (loop_vinfo))
- {
- if (reduction_type != FOLD_LEFT_REDUCTION
- && !mask_by_cond_expr
- && (cond_fn == IFN_LAST
- || !direct_internal_fn_supported_p (cond_fn, vectype_in,
- OPTIMIZE_FOR_SPEED)))
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "can't use a fully-masked loop because no"
- " conditional operation is available.\n");
- LOOP_VINFO_CAN_FULLY_MASK_P (loop_vinfo) = false;
- }
- else if (reduc_index == -1)
- {
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "can't use a fully-masked loop for chained"
- " reductions.\n");
- LOOP_VINFO_CAN_FULLY_MASK_P (loop_vinfo) = false;
- }
- else
- vect_record_loop_mask (loop_vinfo, masks, ncopies * vec_num,
- vectype_in, NULL);
- }
if (dump_enabled_p ()
&& reduction_type == FOLD_LEFT_REDUCTION)
dump_printf_loc (MSG_NOTE, vect_location,
@@ -6367,6 +6337,27 @@ vectorizable_reduction (stmt_vec_info stmt_info, slp_tree slp_node,
STMT_VINFO_DEF_TYPE (stmt_info) = vect_internal_def;
STMT_VINFO_DEF_TYPE (vect_orig_stmt (stmt_info)) = vect_internal_def;
}
+ else if (loop_vinfo && LOOP_VINFO_CAN_FULLY_MASK_P (loop_vinfo))
+ {
+ vec_loop_masks *masks = &LOOP_VINFO_MASKS (loop_vinfo);
+ internal_fn cond_fn = get_conditional_internal_fn (code);
+
+ if (reduction_type != FOLD_LEFT_REDUCTION
+ && !use_mask_by_cond_expr_p (code, cond_fn, vectype_in)
+ && (cond_fn == IFN_LAST
+ || !direct_internal_fn_supported_p (cond_fn, vectype_in,
+ OPTIMIZE_FOR_SPEED)))
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "can't use a fully-masked loop because no"
+ " conditional operation is available.\n");
+ LOOP_VINFO_CAN_FULLY_MASK_P (loop_vinfo) = false;
+ }
+ else
+ vect_record_loop_mask (loop_vinfo, masks, ncopies * vec_num,
+ vectype_in, NULL);
+ }
return true;
}