diff options
author | Richard Biener <rguenther@suse.de> | 2021-01-27 15:20:58 +0100 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2021-01-27 17:33:34 +0100 |
commit | c91db798ec65b3e55f2380ca1530ecb71544f1bb (patch) | |
tree | 04dda92d83caa69419cbc1b51205de5550c0f7b0 /gcc | |
parent | 3fd10728cb1aacf593a7a006ad40e874f791d655 (diff) | |
download | gcc-c91db798ec65b3e55f2380ca1530ecb71544f1bb.zip gcc-c91db798ec65b3e55f2380ca1530ecb71544f1bb.tar.gz gcc-c91db798ec65b3e55f2380ca1530ecb71544f1bb.tar.bz2 |
tree-optimization/98854 - avoid some PHI BB vectorization
This avoids cases of PHI node vectorization that just causes us
to insert vector CTORs inside loops for values only required
outside of the loop.
2021-01-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/98854
* tree-vect-slp.c (vect_build_slp_tree_2): Also build
PHIs from scalars when the number of CTORs matches the
number of children.
* gcc.dg/vect/bb-slp-pr98854.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/bb-slp-pr98854.c | 24 | ||||
-rw-r--r-- | gcc/tree-vect-slp.c | 5 |
2 files changed, 28 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr98854.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98854.c new file mode 100644 index 0000000..0c8141e --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98854.c @@ -0,0 +1,24 @@ +/* { dg-do compile } */ + +double a[1024]; + +int bar(); +void foo (int n) +{ + double x = 0, y = 0; + int i = 1023; + do + { + x += a[i] + a[i+1]; + y += a[i] / a[i+1]; + if (bar ()) + break; + } + while (--i); + /* We want to avoid vectorizing the LC PHI and insert vector CTORs + inside of the loop where it is only needed here. */ + a[0] = x; + a[1] = y; +} + +/* { dg-final { scan-tree-dump-not "vectorizing SLP node starting from: ._\[0-9\]+ = PHI" "slp1" } } */ diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 4465cf7..10b876f 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -1896,7 +1896,10 @@ fail: n_vector_builds++; } } - if (all_uniform_p || n_vector_builds > 1) + if (all_uniform_p + || n_vector_builds > 1 + || (n_vector_builds == children.length () + && is_a <gphi *> (stmt_info->stmt))) { /* Roll back. */ matches[0] = false; |