From: Richard Biener Date: Wed, 9 Sep 2020 08:36:46 +0000 (+0200) Subject: enable live condition vectorization X-Git-Tag: upstream/12.2.0~13884 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=783dc66f9ccb0019c3dad2701bb9110286758d70;p=platform%2Fupstream%2Fgcc.git 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. --- 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 0000000..2dfb879 --- /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 e91bdcb..9c4b800 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 20d13cf..e4d956a 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 065d1bf..e069f87 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);