diff options
author | Richard Biener <rguenther@suse.de> | 2020-10-09 08:56:21 +0200 |
---|---|---|
committer | Richard Biener <rguenther@suse.de> | 2020-10-09 08:59:15 +0200 |
commit | 36500ed18aa89c31b56123aeae43f18fac950674 (patch) | |
tree | 5faf694eac07536d34d8d74a95b6667ee6d7df0c /gcc | |
parent | da9df699753d126e64d72c7ac0d0c0a552417b22 (diff) | |
download | gcc-36500ed18aa89c31b56123aeae43f18fac950674.zip gcc-36500ed18aa89c31b56123aeae43f18fac950674.tar.gz gcc-36500ed18aa89c31b56123aeae43f18fac950674.tar.bz2 |
fix ICE with BB vectorization of PHIs
This fixes a vector CTOR insertion issue when we try to insert after
a PHI node.
2020-10-09 Richard Biener <rguenther@suse.de>
* tree-vect-slp.c (vect_create_constant_vectors): Properly insert
after PHIs.
* gcc.dg/vect/bb-slp-phis-1.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/bb-slp-phis-1.c | 20 | ||||
-rw-r--r-- | gcc/tree-vect-slp.c | 4 |
2 files changed, 23 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-phis-1.c b/gcc/testsuite/gcc.dg/vect/bb-slp-phis-1.c new file mode 100644 index 0000000..014c13b --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-phis-1.c @@ -0,0 +1,20 @@ +/* From gcc.c-torture/execute/loop-13.c */ +/* { dg-do compile } */ +/* { dg-additional-options "-march=cascadelake" { target x86_64-*-* i?86-*-* } } */ +#define TYPE long + +void +scale (TYPE *alpha, TYPE *x, int n) +{ + int i, ix; + + if (*alpha != 1) + for (i = 0, ix = 0; i < n; i++, ix += 2) + { + TYPE tmpr, tmpi; + tmpr = *alpha * x[ix]; + tmpi = *alpha * x[ix + 1]; + x[ix] = tmpr; + x[ix + 1] = tmpi; + } +} diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 7e22506..dbe76ac 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -4144,7 +4144,9 @@ vect_create_constant_vectors (vec_info *vinfo, slp_tree op_node) if (insert_after) { gimple_stmt_iterator gsi; - if (!stmt_ends_bb_p (insert_after->stmt)) + if (gimple_code (insert_after->stmt) == GIMPLE_PHI) + gsi = gsi_after_labels (gimple_bb (insert_after->stmt)); + else if (!stmt_ends_bb_p (insert_after->stmt)) gsi = gsi_for_stmt (insert_after->stmt); else { |