https://gcc.gnu.org/g:337d3cdfa8bb8b8404d62ea45690095f9b566cbb

commit r13-9635-g337d3cdfa8bb8b8404d62ea45690095f9b566cbb
Author: Richard Biener <rguent...@suse.de>
Date:   Thu Aug 24 11:10:43 2023 +0200

    tree-optimization/111125 - avoid BB vectorization in novector loops
    
    When a loop is marked with
    
      #pragma GCC novector
    
    the following makes sure to also skip BB vectorization for contained
    blocks.  That avoids gcc.dg/vect/bb-slp-29.c failing on aarch64
    because of extra BB vectorization therein.  I'm not specifically
    dealing with sub-loops of novector loops, the desired semantics
    isn't documented.
    
            PR tree-optimization/111125
            * tree-vect-slp.cc (vect_slp_function): Split at novector
            loop entry, do not push blocks in novector loops.
    
    (cherry picked from commit 43da77a4f1636280c4259402c9c2c543e6ec6c0b)

Diff:
---
 gcc/tree-vect-slp.cc | 41 +++++++++++++++++++++++++++++------------
 1 file changed, 29 insertions(+), 12 deletions(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index c228087df734..d5b114dbcc9c 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -7714,6 +7714,17 @@ vect_slp_function (function *fun)
                             bbs[0]->loop_father->num, bb->index);
          split = true;
        }
+      else if (!bbs.is_empty ()
+              && bb->loop_father->header == bb
+              && bb->loop_father->dont_vectorize)
+       {
+         if (dump_enabled_p ())
+           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                            "splitting region at dont-vectorize loop %d "
+                            "entry at bb%d\n",
+                            bb->loop_father->num, bb->index);
+         split = true;
+       }
 
       if (split && !bbs.is_empty ())
        {
@@ -7721,19 +7732,25 @@ vect_slp_function (function *fun)
          bbs.truncate (0);
        }
 
-      /* We need to be able to insert at the head of the region which
-        we cannot for region starting with a returns-twice call.  */
       if (bbs.is_empty ())
-       if (gcall *first = safe_dyn_cast <gcall *> (first_stmt (bb)))
-         if (gimple_call_flags (first) & ECF_RETURNS_TWICE)
-           {
-             if (dump_enabled_p ())
-               dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                                "skipping bb%d as start of region as it "
-                                "starts with returns-twice call\n",
-                                bb->index);
-             continue;
-           }
+       {
+         /* We need to be able to insert at the head of the region which
+            we cannot for region starting with a returns-twice call.  */
+         if (gcall *first = safe_dyn_cast <gcall *> (first_stmt (bb)))
+           if (gimple_call_flags (first) & ECF_RETURNS_TWICE)
+             {
+               if (dump_enabled_p ())
+                 dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                                  "skipping bb%d as start of region as it "
+                                  "starts with returns-twice call\n",
+                                  bb->index);
+               continue;
+             }
+         /* If the loop this BB belongs to is marked as not to be vectorized
+            honor that also for BB vectorization.  */
+         if (bb->loop_father->dont_vectorize)
+           continue;
+       }
 
       bbs.safe_push (bb);

Reply via email to