aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorKewen Lin <linkw@linux.ibm.com>2020-07-08 22:27:41 -0500
committerKewen Lin <linkw@linux.ibm.com>2020-07-09 02:23:42 -0500
commit2a39c42a42cdea4a8962b9e140b88e0051894f38 (patch)
tree4c638fd1a50d266774838974eab175006fbbd2f4 /gcc
parent23fb9e7c1c403a256b158fdfc97f7f32f636d3d0 (diff)
downloadgcc-2a39c42a42cdea4a8962b9e140b88e0051894f38.zip
gcc-2a39c42a42cdea4a8962b9e140b88e0051894f38.tar.gz
gcc-2a39c42a42cdea4a8962b9e140b88e0051894f38.tar.bz2
vect: Enhance condition check to use partial vectors
This patch is derived from the review of vector with length patch series. The length-based partial vector approach doesn't support reduction so far, so we would like to disable vectorization with partial vectors explicitly for it in vectorizable_condition. Otherwise, it will cause some unexpected failures for a few cases like gcc.dg/vect/pr65947-2.c. But if we disable it for the cases excepting for reduction_type equal to EXTRACT_LAST_REDUCTION, it cause one regression failure on aarch64: gcc.target/aarch64/sve/reduc_8.c -march=armv8.2-a+sve The disabling makes the outer loop can't work with partial vectors, the check fails. But the case is safe to adopt it. As Richard S. pointed out in the review comments, the extra inactive lanes only matter for double reductions, so this patch is to permit vectorization with partial vectors for cases EXTRACT_LAST_REDUCTION or nested-cycle reduction. Bootstrapped/regtested on aarch64-linux-gnu. gcc/ChangeLog: * tree-vect-stmts.c (vectorizable_condition): Prohibit vectorization with partial vectors explicitly excepting for EXTRACT_LAST_REDUCTION or nested-cycle reduction.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/tree-vect-stmts.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index cec5c60..5eae74e 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -9876,11 +9876,22 @@ vectorizable_condition (vec_info *vinfo,
return false;
}
- if (loop_vinfo
- && LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo)
- && reduction_type == EXTRACT_LAST_REDUCTION)
- vect_record_loop_mask (loop_vinfo, &LOOP_VINFO_MASKS (loop_vinfo),
- ncopies * vec_num, vectype, NULL);
+ if (loop_vinfo && for_reduction
+ && LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo))
+ {
+ if (reduction_type == EXTRACT_LAST_REDUCTION)
+ vect_record_loop_mask (loop_vinfo, &LOOP_VINFO_MASKS (loop_vinfo),
+ ncopies * vec_num, vectype, NULL);
+ /* Extra inactive lanes should be safe for vect_nested_cycle. */
+ else if (STMT_VINFO_DEF_TYPE (reduc_info) != vect_nested_cycle)
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "conditional reduction prevents the use"
+ " of partial vectors.\n");
+ LOOP_VINFO_CAN_USE_PARTIAL_VECTORS_P (loop_vinfo) = false;
+ }
+ }
STMT_VINFO_TYPE (stmt_info) = condition_vec_info_type;
vect_model_simple_cost (vinfo, stmt_info, ncopies, dts, ndts, slp_node,