enable live comparison vectorization

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.
This commit is contained in:
Richard Biener 2020-09-09 12:05:55 +02:00
parent cbc12c5824
commit db918db2c3
2 changed files with 31 additions and 8 deletions

View file

@ -0,0 +1,31 @@
#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 } } } */

View file

@ -10319,14 +10319,6 @@ vectorizable_comparison (vec_info *vinfo,
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;