diff options
author | Richard Biener <rguenther@suse.de> | 2019-12-06 07:53:15 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2019-12-06 07:53:15 +0000 |
commit | 2ef278569f60a2c1556f1752aeba39c586521371 (patch) | |
tree | 327828c5b3bda519cfed60d710e3a2d0e8e895c5 /gcc/match.pd | |
parent | 9961856c3acb8e7d9def11b58001db6af9f14253 (diff) |
re PR tree-optimization/92819 (Worse code generated on avx2 due to simplify_vector_constructor)
2019-12-06 Richard Biener <rguenther@suse.de>
PR tree-optimization/92819
* match.pd (VEC_PERM_EXPR -> BIT_INSERT_EXPR): Handle inserts
into the last lane. For two-element vectors try inserting
into the last lane when inserting into the first fails.
* gcc.target/i386/pr92819-1.c: New testcase.
* gcc.target/i386/pr92803.c: Adjust.
From-SVN: r279033
Diffstat (limited to 'gcc/match.pd')
-rw-r--r-- | gcc/match.pd | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/match.pd b/gcc/match.pd index 68027f6757d..e32d8009647 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -6032,7 +6032,8 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) || TREE_CODE (cop1) == VECTOR_CST || TREE_CODE (cop1) == CONSTRUCTOR)) { - if (sel.series_p (1, 1, nelts + 1, 1)) + bool insert_first_p = sel.series_p (1, 1, nelts + 1, 1); + if (insert_first_p) { /* After canonicalizing the first elt to come from the first vector we only can insert the first elt from @@ -6041,13 +6042,19 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) if ((ins = fold_read_from_vector (cop0, sel[0]))) op0 = op1; } - else + /* The above can fail for two-element vectors which always + appear to insert the first element, so try inserting + into the second lane as well. For more than two + elements that's wasted time. */ + if (!insert_first_p || (!ins && maybe_eq (nelts, 2u))) { unsigned int encoded_nelts = sel.encoding ().encoded_nelts (); for (at = 0; at < encoded_nelts; ++at) if (maybe_ne (sel[at], at)) break; - if (at < encoded_nelts && sel.series_p (at + 1, 1, at + 1, 1)) + if (at < encoded_nelts + && (known_eq (at + 1, nelts) + || sel.series_p (at + 1, 1, at + 1, 1))) { if (known_lt (poly_uint64 (sel[at]), nelts)) ins = fold_read_from_vector (cop0, sel[at]); |