This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Avoid useless work in loop vectorization
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 13 Nov 2015 09:41:31 +0100 (CET)
- Subject: [PATCH] Avoid useless work in loop vectorization
- Authentication-results: sourceware.org; auth=none
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2015-11-13 Richard Biener <rguenther@suse.de>
* tree-vect-loop.c (vect_analyze_loop_2): Add fatal parameter.
Signal fatal failure if early checks fail.
(vect_analyze_loop): If vect_analyze_loop_2 fails fatally
do not bother testing further vector sizes.
Index: gcc/tree-vect-loop.c
===================================================================
--- gcc/tree-vect-loop.c (revision 230260)
+++ gcc/tree-vect-loop.c (working copy)
@@ -1709,13 +1709,16 @@ vect_analyze_loop_operations (loop_vec_i
for it. The different analyses will record information in the
loop_vec_info struct. */
static bool
-vect_analyze_loop_2 (loop_vec_info loop_vinfo)
+vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool &fatal)
{
bool ok;
int max_vf = MAX_VECTORIZATION_FACTOR;
int min_vf = 2;
unsigned int n_stmts = 0;
+ /* The first group of checks is independent of the vector size. */
+ fatal = true;
+
/* Find all data references in the loop (which correspond to vdefs/vuses)
and analyze their evolution in the loop. */
@@ -1795,7 +1798,6 @@ vect_analyze_loop_2 (loop_vec_info loop_
/* Classify all cross-iteration scalar data-flow cycles.
Cross-iteration cycles caused by virtual phis are analyzed separately. */
-
vect_analyze_scalar_cycles (loop_vinfo);
vect_pattern_recog (loop_vinfo);
@@ -1825,6 +1827,9 @@ vect_analyze_loop_2 (loop_vec_info loop_
return false;
}
+ /* While the rest of the analysis below depends on it in some way. */
+ fatal = false;
+
/* Analyze data dependences between the data-refs in the loop
and adjust the maximum vectorization factor according to
the dependences.
@@ -2118,7 +2169,8 @@ vect_analyze_loop (struct loop *loop)
return NULL;
}
- if (vect_analyze_loop_2 (loop_vinfo))
+ bool fatal = false;
+ if (vect_analyze_loop_2 (loop_vinfo, fatal))
{
LOOP_VINFO_VECTORIZABLE_P (loop_vinfo) = 1;
@@ -2128,7 +2180,8 @@ vect_analyze_loop (struct loop *loop)
destroy_loop_vec_info (loop_vinfo, true);
vector_sizes &= ~current_vector_size;
- if (vector_sizes == 0
+ if (fatal
+ || vector_sizes == 0
|| current_vector_size == 0)
return NULL;