tree-optimization/93094 pass down VECTORIZED_CALL to versioning
authorRichard Biener <rguenther@suse.de>
Wed, 15 Jan 2020 13:25:38 +0000 (14:25 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 20 Jan 2020 08:48:42 +0000 (09:48 +0100)
When versioning is run the IL is already mangled and finding
a VECTORIZED_CALL IFN can fail.

2020-01-20  Richard Biener  <rguenther@suse.de>

PR tree-optimization/93094
* tree-vectorizer.h (vect_loop_versioning): Adjust.
(vect_transform_loop): Likewise.
* tree-vectorizer.c (try_vectorize_loop_1): Pass down
loop_vectorized_call to vect_transform_loop.
* tree-vect-loop.c (vect_transform_loop): Pass down
loop_vectorized_call to vect_loop_versioning.
* tree-vect-loop-manip.c (vect_loop_versioning): Use
the earlier discovered loop_vectorized_call.

* gcc.dg/vect/pr93094.c: New testcase.

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr93094.c [new file with mode: 0644]
gcc/tree-vect-loop-manip.c
gcc/tree-vect-loop.c
gcc/tree-vectorizer.c
gcc/tree-vectorizer.h

index b6758fe479a7d273cf265e6bbd0abc5e84cb5d72..9d493cc4386f08dda07e6ec66dfeaee8b18fd0fa 100644 (file)
@@ -1,3 +1,15 @@
+2020-01-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/93094
+       * tree-vectorizer.h (vect_loop_versioning): Adjust.
+       (vect_transform_loop): Likewise.
+       * tree-vectorizer.c (try_vectorize_loop_1): Pass down
+       loop_vectorized_call to vect_transform_loop.
+       * tree-vect-loop.c (vect_transform_loop): Pass down
+       loop_vectorized_call to vect_loop_versioning.
+       * tree-vect-loop-manip.c (vect_loop_versioning): Use
+       the earlier discovered loop_vectorized_call.
+
 2020-01-19  Eric S. Raymond <esr@thyrsus.com>
 
        * doc/contribute.texi: Update for SVN -> Git transition.
index 96570a901868bdc33331b178f4eb1a8da5728a26..cae0c163e39f84e66f157e321967a5f9bf47bc4f 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-20  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/93094
+       * gcc.dg/vect/pr93094.c: New testcase.
+
 2020-01-19  David Malcolm  <dmalcolm@redhat.com>
 
        * gcc.dg/analyzer/CVE-2005-1689-dedupe-issue.c: Ensure that all
diff --git a/gcc/testsuite/gcc.dg/vect/pr93094.c b/gcc/testsuite/gcc.dg/vect/pr93094.c
new file mode 100644 (file)
index 0000000..79c3e89
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3 -fno-tree-pre" } */
+/* { dg-additional-options "-mavx512bw" { target x86_64-*-* i?86-*-* } } */
+
+void
+ll (char *un, char *rr, int te, int fp, int nb)
+{
+  const int xe = nb & 1;
+
+  while (fp-- != 0)
+    {
+      if ((rr[0] & xe) == 0)
+        un[0] = 0;
+
+      un += te;
+      rr += te;
+    }
+}
index 52ca4e3e56c494edd3e73c627be4ccec43d79243..0ee1ab45c07d548d8938ae75f5c655b504b74f1e 100644 (file)
@@ -3205,7 +3205,8 @@ vect_create_cond_for_alias_checks (loop_vec_info loop_vinfo, tree * cond_expr)
    *COND_EXPR_STMT_LIST.  */
 
 class loop *
-vect_loop_versioning (loop_vec_info loop_vinfo)
+vect_loop_versioning (loop_vec_info loop_vinfo,
+                     gimple *loop_vectorized_call)
 {
   class loop *loop = LOOP_VINFO_LOOP (loop_vinfo), *nloop;
   class loop *scalar_loop = LOOP_VINFO_SCALAR_LOOP (loop_vinfo);
@@ -3339,18 +3340,18 @@ vect_loop_versioning (loop_vec_info loop_vinfo)
      if-conversion re-use that.  Note we cannot re-use the copy of
      an if-converted outer-loop when vectorizing the inner loop only.  */
   gcond *cond;
-  gimple *call;
   if ((!loop_to_version->inner || loop == loop_to_version)
-      && (call = vect_loop_vectorized_call (loop_to_version, &cond)))
+      && loop_vectorized_call)
     {
       gcc_assert (scalar_loop);
-      condition_bb = gimple_bb (cond);
+      condition_bb = gimple_bb (loop_vectorized_call);
+      cond = as_a <gcond *> (last_stmt (condition_bb));
       gimple_cond_set_condition_from_tree (cond, cond_expr);
       update_stmt (cond);
 
       if (cond_expr_stmt_list)
        {
-         cond_exp_gsi = gsi_for_stmt (call);
+         cond_exp_gsi = gsi_for_stmt (loop_vectorized_call);
          gsi_insert_seq_before (&cond_exp_gsi, cond_expr_stmt_list,
                                 GSI_SAME_STMT);
        }
index e5fb434bd4e5d98587791287d51d3e8ea7d1460f..b4cfad875ab1dad18a325401b0648bef155056ec 100644 (file)
@@ -8487,7 +8487,7 @@ update_epilogue_loop_vinfo (class loop *epilogue, tree advance)
    Returns scalar epilogue loop if any.  */
 
 class loop *
-vect_transform_loop (loop_vec_info loop_vinfo)
+vect_transform_loop (loop_vec_info loop_vinfo, gimple *loop_vectorized_call)
 {
   class loop *loop = LOOP_VINFO_LOOP (loop_vinfo);
   class loop *epilogue = NULL;
@@ -8538,7 +8538,7 @@ vect_transform_loop (loop_vec_info loop_vinfo)
   if (LOOP_REQUIRES_VERSIONING (loop_vinfo))
     {
       class loop *sloop
-       = vect_loop_versioning (loop_vinfo);
+       = vect_loop_versioning (loop_vinfo, loop_vectorized_call);
       sloop->force_vectorize = false;
       check_profitability = false;
     }
index aa22fd1034c78b8e81bbd7a4d7efde372e33aba6..8f9444d58a3248c028a192625c22ce1650fc9027 100644 (file)
@@ -986,7 +986,8 @@ try_vectorize_loop_1 (hash_table<simduid_to_vf> *&simduid_to_vf_htab,
                         "loop vectorized using variable length vectors\n");
     }
 
-  loop_p new_loop = vect_transform_loop (loop_vinfo);
+  loop_p new_loop = vect_transform_loop (loop_vinfo,
+                                        loop_vectorized_call);
   (*num_vectorized_loops)++;
   /* Now that the loop has been vectorized, allow it to be unrolled
      etc.  */
index ed7fcb0b825aa78537fea3994183484fdbd66f62..f7becb34ab41c645e5e76065377d78f2af39a09a 100644 (file)
@@ -1682,7 +1682,7 @@ extern void vect_set_loop_condition (class loop *, loop_vec_info,
 extern bool slpeel_can_duplicate_loop_p (const class loop *, const_edge);
 class loop *slpeel_tree_duplicate_loop_to_edge_cfg (class loop *,
                                                     class loop *, edge);
-class loop *vect_loop_versioning (loop_vec_info);
+class loop *vect_loop_versioning (loop_vec_info, gimple *);
 extern class loop *vect_do_peeling (loop_vec_info, tree, tree,
                                    tree *, tree *, tree *, int, bool, bool,
                                    tree *);
@@ -1821,7 +1821,7 @@ extern tree vect_get_loop_mask (gimple_stmt_iterator *, vec_loop_masks *,
 extern stmt_vec_info info_for_reduction (stmt_vec_info);
 
 /* Drive for loop transformation stage.  */
-extern class loop *vect_transform_loop (loop_vec_info);
+extern class loop *vect_transform_loop (loop_vec_info, gimple *);
 extern opt_loop_vec_info vect_analyze_loop_form (class loop *,
                                                 vec_info_shared *);
 extern bool vectorizable_live_operation (stmt_vec_info, gimple_stmt_iterator *,