aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBin Cheng <bin.cheng@arm.com>2017-06-07 10:56:54 +0000
committerBin Cheng <amker@gcc.gnu.org>2017-06-07 10:56:54 +0000
commit704c28eeebfa5fc3fb555eb980f149ca76a8b948 (patch)
tree41d76aa330fbf57d65b3adc3737650006fbd3a4c
parent7078979b291419f353804cc32ecfdb22367b6e0d (diff)
downloadgcc-704c28eeebfa5fc3fb555eb980f149ca76a8b948.zip
gcc-704c28eeebfa5fc3fb555eb980f149ca76a8b948.tar.gz
gcc-704c28eeebfa5fc3fb555eb980f149ca76a8b948.tar.bz2
tree-vect-loop-manip.c (vect_do_peeling): Don't skip vector loop if versioning is required.
* tree-vect-loop-manip.c (vect_do_peeling): Don't skip vector loop if versioning is required. * tree-vect-loop.c (vect_analyze_loop_2): Merge niter check for loop peeling with the check for versioning. From-SVN: r248959
-rw-r--r--gcc/ChangeLog7
-rw-r--r--gcc/tree-vect-loop-manip.c8
-rw-r--r--gcc/tree-vect-loop.c30
3 files changed, 42 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f83e059..8198e0c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,12 @@
2017-06-07 Bin Cheng <bin.cheng@arm.com>
+ * tree-vect-loop-manip.c (vect_do_peeling): Don't skip vector loop
+ if versioning is required.
+ * tree-vect-loop.c (vect_analyze_loop_2): Merge niter check for loop
+ peeling with the check for versioning.
+
+2017-06-07 Bin Cheng <bin.cheng@arm.com>
+
* tree-vectorizer.h (vect_build_loop_niters): New parameter.
* tree-vect-loop-manip.c (vect_build_loop_niters): New parameter.
Set true to new parameter if new ssa variable is defined.
diff --git a/gcc/tree-vect-loop-manip.c b/gcc/tree-vect-loop-manip.c
index 0156c97..d60b84e 100644
--- a/gcc/tree-vect-loop-manip.c
+++ b/gcc/tree-vect-loop-manip.c
@@ -1691,9 +1691,11 @@ vect_do_peeling (loop_vec_info loop_vinfo, tree niters, tree nitersm1,
/* Prolog loop may be skipped. */
bool skip_prolog = (prolog_peeling != 0);
- /* Skip to epilog if scalar loop may be preferred. It's only used when
- we peel for epilog loop. */
- bool skip_vector = (!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo));
+ /* Skip to epilog if scalar loop may be preferred. It's only needed
+ when we peel for epilog loop and when it hasn't been checked with
+ loop versioning. */
+ bool skip_vector = (!LOOP_VINFO_NITERS_KNOWN_P (loop_vinfo)
+ && !LOOP_REQUIRES_VERSIONING (loop_vinfo));
/* Epilog loop must be executed if the number of iterations for epilog
loop is known at compile time, otherwise we need to add a check at
the end of vector loop and skip to the end of epilog loop. */
diff --git a/gcc/tree-vect-loop.c b/gcc/tree-vect-loop.c
index f81eb6f..92d9a28 100644
--- a/gcc/tree-vect-loop.c
+++ b/gcc/tree-vect-loop.c
@@ -2220,6 +2220,36 @@ start_over:
}
}
+ /* During peeling, we need to check if number of loop iterations is
+ enough for both peeled prolog loop and vector loop. This check
+ can be merged along with threshold check of loop versioning, so
+ increase threshold for this case if necessary. */
+ if (LOOP_REQUIRES_VERSIONING (loop_vinfo)
+ && (LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo)
+ || LOOP_VINFO_PEELING_FOR_NITER (loop_vinfo)))
+ {
+ unsigned niters_th;
+
+ /* Niters for peeled prolog loop. */
+ if (LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo) < 0)
+ {
+ struct data_reference *dr = LOOP_VINFO_UNALIGNED_DR (loop_vinfo);
+ tree vectype = STMT_VINFO_VECTYPE (vinfo_for_stmt (DR_STMT (dr)));
+
+ niters_th = TYPE_VECTOR_SUBPARTS (vectype) - 1;
+ }
+ else
+ niters_th = LOOP_VINFO_PEELING_FOR_ALIGNMENT (loop_vinfo);
+
+ /* Niters for at least one iteration of vectorized loop. */
+ niters_th += LOOP_VINFO_VECT_FACTOR (loop_vinfo);
+ /* One additional iteration because of peeling for gap. */
+ if (!LOOP_VINFO_PEELING_FOR_GAPS (loop_vinfo))
+ niters_th++;
+ if (LOOP_VINFO_COST_MODEL_THRESHOLD (loop_vinfo) < niters_th)
+ LOOP_VINFO_COST_MODEL_THRESHOLD (loop_vinfo) = niters_th;
+ }
+
gcc_assert (vectorization_factor
== (unsigned)LOOP_VINFO_VECT_FACTOR (loop_vinfo));