This removes a check preventing vectorization of live results of
vectorized comparisons. I tested it with AVX512 mask registers
(inspecting assembly) and traditional vector masks.
2020-09-09 Richard Biener <rguenther@suse.de>
* tree-vect-stmts.c (vectorizable_comparison): Allow
STMT_VINFO_LIVE_P stmts.
* gcc.dg/vect/vect-live-6.c: New testcase.
--- /dev/null
+#include "tree-vect.h"
+
+int a[1024];
+int b[1024];
+
+_Bool
+fn1 ()
+{
+ _Bool tem;
+ for (int i = 0; i < 1024; ++i)
+ {
+ tem = !a[i];
+ b[i] = tem;
+ }
+ return tem;
+}
+
+int main()
+{
+ check_vect ();
+ for (int i = 0; i < 1024; ++i)
+ {
+ a[i] = i & 5;
+ __asm__ volatile ("" ::: "memory");
+ }
+ if (fn1 () != !(1023 & 5) || b[2] != 1)
+ abort ();
+ return 0;
+}
+
+/* { dg-final { scan-tree-dump "vectorized 1 loops" "vect" { target vect_int } } } */
if (STMT_VINFO_DEF_TYPE (stmt_info) != vect_internal_def)
return false;
- 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;
- }
-
gassign *stmt = dyn_cast <gassign *> (stmt_info->stmt);
if (!stmt)
return false;