tree-optimization/97746 - fix order of mask precision computes
authorRichard Biener <rguenther@suse.de>
Mon, 9 Nov 2020 12:55:11 +0000 (13:55 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 9 Nov 2020 13:57:10 +0000 (14:57 +0100)
This fixes the order of walking PHIs and stmts for BB mask
precision compute.

2020-11-09  Richard Biener  <rguenther@suse.de>

PR tree-optimization/97746
* tree-vect-patterns.c (vect_determine_precisions): First walk PHIs.

* gcc.dg/vect/bb-slp-pr97746.c: New testcase.

gcc/testsuite/gcc.dg/vect/bb-slp-pr97746.c [new file with mode: 0644]
gcc/tree-vect-patterns.c

diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr97746.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr97746.c
new file mode 100644 (file)
index 0000000..c5a615d
--- /dev/null
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+
+int a, b;
+short c;
+
+extern void f (short*);
+
+void d()
+{
+  short e[2] = {0, 0};
+  while (a)
+    {
+      f(e);
+      int g = 0 || a, h = 8 && c;
+      short i = c;
+      c = h & g;
+      if (b)
+       b = g || i;
+    }
+}
index eefa7cf6799a7d846303aa6274d28bcc0a841158..f68a87e05ed54145a25ccff598eeef9e57f9a759 100644 (file)
@@ -5182,15 +5182,15 @@ vect_determine_precisions (vec_info *vinfo)
       for (unsigned i = 0; i < bb_vinfo->bbs.length (); ++i)
        {
          basic_block bb = bb_vinfo->bbs[i];
-         for (auto gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+         for (auto gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
            {
-             stmt_vec_info stmt_info = vinfo->lookup_stmt (gsi_stmt (gsi));
+             stmt_vec_info stmt_info = vinfo->lookup_stmt (gsi.phi ());
              if (stmt_info && STMT_VINFO_VECTORIZABLE (stmt_info))
                vect_determine_mask_precision (vinfo, stmt_info);
            }
-         for (auto gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+         for (auto gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
            {
-             stmt_vec_info stmt_info = vinfo->lookup_stmt (gsi.phi ());
+             stmt_vec_info stmt_info = vinfo->lookup_stmt (gsi_stmt (gsi));
              if (stmt_info && STMT_VINFO_VECTORIZABLE (stmt_info))
                vect_determine_mask_precision (vinfo, stmt_info);
            }