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.
--- /dev/null
+/* { 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 } } } */
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 } } */
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 } } */
{
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);