enable live condition vectorization
authorRichard Biener <rguenther@suse.de>
Wed, 9 Sep 2020 08:36:46 +0000 (10:36 +0200)
committerRichard Biener <rguenther@suse.de>
Wed, 9 Sep 2020 09:36:19 +0000 (11:36 +0200)
This removes a check preventing vectorization of live results of
vectorized conditions.

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

* tree-vect-stmts.c (vectorizable_condition): Allow
STMT_VINFO_LIVE_P stmts.

* gcc.dg/vect/vect-cond-13.c: New testcase.
* gcc.target/i386/pr87007-4.c: Adjust.
* gcc.target/i386/pr87007-5.c: Likewise.

gcc/testsuite/gcc.dg/vect/vect-cond-13.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/pr87007-4.c
gcc/testsuite/gcc.target/i386/pr87007-5.c
gcc/tree-vect-stmts.c

diff --git a/gcc/testsuite/gcc.dg/vect/vect-cond-13.c b/gcc/testsuite/gcc.dg/vect/vect-cond-13.c
new file mode 100644 (file)
index 0000000..2dfb879
--- /dev/null
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+
+#include "tree-vect.h"
+
+int a[1024];
+int b[1024];
+
+int
+foo ()
+{
+  int tem;
+  for (int i = 0; i < 1024; ++i)
+    {
+      if (a[i] < 0)
+        tem = -a[i] - 1;
+      else
+        tem = a[i];
+      b[i] = tem + 10;
+    }
+  return tem;
+}
+
+int main()
+{
+  check_vect ();
+
+  for (int i = 0; i < 1024; ++i)
+    {
+      a[i] = i - 333;
+      __asm__ volatile ("" ::: "memory");
+    }
+  int res = foo ();
+  if (res != 1023 - 333)
+    abort ();
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target vect_condition } } } */
index e91bdcbac44b2510d6462fbf03e82f948467395f..9c4b8005af30b50a39ba5de8f0eb197711830cd3 100644 (file)
@@ -15,4 +15,4 @@ foo (int n, int k)
       d1 = ceil (d3);
 }
 
-/* { dg-final { scan-assembler-times "vxorps\[^\n\r\]*xmm\[0-9\]" 1 } } */
+/* { dg-final { scan-assembler-times "vxorps\[^\n\r\]*xmm\[0-9\]" 0 } } */
index 20d13cf650b9100f5c07b5a16c456d2dcc2b1e1e..e4d956a5d7fb8d2d85f0da4cc4670fec99f48225 100644 (file)
@@ -15,4 +15,4 @@ foo (int n, int k)
       d1 = sqrt (d3);
 }
 
-/* { dg-final { scan-assembler-times "vxorps\[^\n\r\]*xmm\[0-9\]" 1 } } */
+/* { dg-final { scan-assembler-times "vxorps\[^\n\r\]*xmm\[0-9\]" 0 } } */
index 065d1bf3cafacacc99099f8861a93504d325683f..e069f874f72537a5236a27836fd37e87626b4e7f 100644 (file)
@@ -9853,15 +9853,6 @@ vectorizable_condition (vec_info *vinfo,
     {
       if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_internal_def)
        return false;
-
-      /* FORNOW: only supported as part of a reduction.  */
-      if (loop_vinfo && STMT_VINFO_LIVE_P (stmt_info))
-       {
-         if (dump_enabled_p ())
-           dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                            "value used after loop.\n");
-         return false;
-       }
     }
 
   tree vectype = STMT_VINFO_VECTYPE (stmt_info);