re PR tree-optimization/78396 (gcc.dg/vect/bb-slp-cond-1.c FAILs after fix for PR77848)
authorRichard Biener <rguenther@suse.de>
Wed, 23 Nov 2016 14:40:05 +0000 (14:40 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 23 Nov 2016 14:40:05 +0000 (14:40 +0000)
2016-11-23  Richard Biener  <rguenther@suse.de>

PR tree-optimization/78396
* tree-vectorizer.c (vectorize_loops): If an innermost loop didn't
vectorize try vectorizing an if-converted body using BB vectorization.

* gcc.dg/vect/bb-slp-cond-1.c: Adjust.

From-SVN: r242759

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/bb-slp-cond-1.c
gcc/tree-vectorizer.c

index a931d1ef03ae81d6b881fca25545f3cda8ee6b15..a5f757c4e172c20c4b9bbe36e33ce8a54732b24c 100644 (file)
@@ -1,3 +1,9 @@
+2016-11-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/78396
+       * tree-vectorizer.c (vectorize_loops): If an innermost loop didn't
+       vectorize try vectorizing an if-converted body using BB vectorization.
+
 2016-11-23  Richard Sandiford  <richard.sandiford@arm.com>
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
index db8b8974947e32ee0a26191be0bcbf17cb4a5183..7bdb38ac14209c3b36a37310b05121dc4989ab4e 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-23  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/78396
+       * gcc.dg/vect/bb-slp-cond-1.c: Adjust.
+
 2016-11-23  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/78482
index 35811bd3e24a99035b3d1a4edb0bea3b72773f8e..ddad85374b615d7fe3e1e3d411f139c0160e713c 100644 (file)
@@ -1,4 +1,5 @@
 /* { dg-require-effective-target vect_condition } */
+/* { dg-additional-options "-fdump-tree-vect-details" } */
 
 #include "tree-vect.h"
 
@@ -41,5 +42,10 @@ int main ()
   return 0;
 }
 
-/* { dg-final { scan-tree-dump-times "basic block vectorized" 1 "slp1" { target vect_element_align } } } */
+/* Basic blocks of if-converted loops are vectorized from within the loop
+   vectorizer pass.  In this case it is really a deficiency in loop
+   vectorization data dependence analysis that causes us to require
+   basic block vectorization in the first place.  */
+
+/* { dg-final { scan-tree-dump-times "basic block vectorized" 1 "vect" { target vect_element_align } } } */
 
index 35d7a3ee0c574170b38da65121164697e9991e05..b3906643b8f6506b8fad6b5b014e02b4a0476fb0 100644 (file)
@@ -540,6 +540,7 @@ vectorize_loops (void)
             || loop->force_vectorize)
       {
        loop_vec_info loop_vinfo, orig_loop_vinfo = NULL;
+       gimple *loop_vectorized_call = vect_loop_vectorized_call (loop);
 vectorize_epilogue:
        vect_location = find_loop_location (loop);
         if (LOCATION_LOCUS (vect_location) != UNKNOWN_LOCATION
@@ -558,6 +559,33 @@ vectorize_epilogue:
            if (loop_constraint_set_p (loop, LOOP_C_FINITE))
              vect_free_loop_info_assumptions (loop);
 
+           /* If we applied if-conversion then try to vectorize the
+              BB of innermost loops.
+              ???  Ideally BB vectorization would learn to vectorize
+              control flow by applying if-conversion on-the-fly, the
+              following retains the if-converted loop body even when
+              only non-if-converted parts took part in BB vectorization.  */
+           if (flag_tree_slp_vectorize != 0
+               && loop_vectorized_call
+               && ! loop->inner)
+             {
+               basic_block bb = loop->header;
+               for (gimple_stmt_iterator gsi = gsi_start_bb (bb);
+                    !gsi_end_p (gsi); gsi_next (&gsi))
+                 {
+                   gimple *stmt = gsi_stmt (gsi);
+                   gimple_set_uid (stmt, -1);
+                   gimple_set_visited (stmt, false);
+                 }
+               if (vect_slp_bb (bb))
+                 {
+                   dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location,
+                                    "basic block vectorized\n");
+                   fold_loop_vectorized_call (loop_vectorized_call,
+                                              boolean_true_node);
+                   ret |= TODO_cleanup_cfg;
+                 }
+             }
            continue;
          }
 
@@ -575,7 +603,6 @@ vectorize_epilogue:
            break;
          }
 
-       gimple *loop_vectorized_call = vect_loop_vectorized_call (loop);
        if (loop_vectorized_call)
          set_uid_loop_bbs (loop_vinfo, loop_vectorized_call);
         if (LOCATION_LOCUS (vect_location) != UNKNOWN_LOCATION