From 783dc66f9ccb0019c3dad2701bb9110286758d70 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 9 Sep 2020 10:36:46 +0200 Subject: [PATCH] enable live condition vectorization This removes a check preventing vectorization of live results of vectorized conditions. 2020-09-09 Richard Biener * 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 | 38 +++++++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr87007-4.c | 2 +- gcc/testsuite/gcc.target/i386/pr87007-5.c | 2 +- gcc/tree-vect-stmts.c | 9 ------ 4 files changed, 40 insertions(+), 11 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/vect-cond-13.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 index 00000000000..2dfb8797cd8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/vect-cond-13.c @@ -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 } } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr87007-4.c b/gcc/testsuite/gcc.target/i386/pr87007-4.c index e91bdcbac44..9c4b8005af3 100644 --- a/gcc/testsuite/gcc.target/i386/pr87007-4.c +++ b/gcc/testsuite/gcc.target/i386/pr87007-4.c @@ -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 } } */ diff --git a/gcc/testsuite/gcc.target/i386/pr87007-5.c b/gcc/testsuite/gcc.target/i386/pr87007-5.c index 20d13cf650b..e4d956a5d7f 100644 --- a/gcc/testsuite/gcc.target/i386/pr87007-5.c +++ b/gcc/testsuite/gcc.target/i386/pr87007-5.c @@ -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 } } */ diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c index 065d1bf3caf..e069f874f72 100644 --- a/gcc/tree-vect-stmts.c +++ b/gcc/tree-vect-stmts.c @@ -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); -- 2.30.2