This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/78396] [7 regression] gcc.dg/vect/bb-slp-cond-1.c FAILs after fix for PR77848


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78396

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Something like the following looks most reasonable (testcase needs adjustment
to scan the "vect" dump of course):

diff --git a/gcc/tree-vectorizer.c b/gcc/tree-vectorizer.c
index 35d7a3e..8c06725 100644
--- a/gcc/tree-vectorizer.c
+++ b/gcc/tree-vectorizer.c
@@ -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,32 @@ 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 (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 +602,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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]