aboutsummaryrefslogtreecommitdiff
path: root/gcc/match.pd
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-04-15 13:03:21 +0200
committerRichard Biener <rguenther@suse.de>2021-04-26 11:04:00 +0200
commitb972e036f40c12b106f9070c3e8adea0eb8a45fa (patch)
treec7ea13fc150948db248df196e567eac1c4ddd729 /gcc/match.pd
parent152334cfb7a17bb3f1356f31a2e808d3ee459605 (diff)
downloadgcc-b972e036f40c12b106f9070c3e8adea0eb8a45fa.zip
gcc-b972e036f40c12b106f9070c3e8adea0eb8a45fa.tar.gz
gcc-b972e036f40c12b106f9070c3e8adea0eb8a45fa.tar.bz2
Move gimplify_buildN API local to only remaining user
This moves the legacy gimplify_buildN API to tree-vect-generic.c, its only user and elides the gimplification step, making it a wrapper around gimple_build, adjusting tree_vec_extract for this. I've noticed that vector CTOR expansion doesn't deal with unfolded {} and thus this makes it more resilent. I've also adjusted the match.pd vector CTOR extraction code to make sure it doesn't produce a CTOR when folding would make it a vector constant. 2021-04-15 Richard Biener <rguenther@suse.de> * tree-cfg.h (gimplify_build1): Remove. (gimplify_build2): Likewise. (gimplify_build3): Likewise. * tree-cfg.c (gimplify_build1): Move to tree-vect-generic.c. (gimplify_build2): Likewise. (gimplify_build3): Likewise. * tree-vect-generic.c (gimplify_build1): Move from tree-cfg.c. Modernize. (gimplify_build2): Likewise. (gimplify_build3): Likewise. (tree_vec_extract): Use resimplify with following SSA edges. (expand_vector_parallel): Avoid passing NULL size/bitpos to tree_vec_extract. * expr.c (store_constructor): Deal with zero-element CTORs. * match.pd (bit_field_ref <vector CTOR>): Make sure to produce vector constants when possible.
Diffstat (limited to 'gcc/match.pd')
-rw-r--r--gcc/match.pd29
1 files changed, 19 insertions, 10 deletions
diff --git a/gcc/match.pd b/gcc/match.pd
index 3ffd9a6..66788ba 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -6203,7 +6203,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
/* We keep an exact subset of the constructor elements. */
(if (multiple_p (idx, k, &elt) && multiple_p (n, k, &count))
(if (CONSTRUCTOR_NELTS (ctor) == 0)
- { build_constructor (type, NULL); }
+ { build_zero_cst (type); }
(if (count == 1)
(if (elt < CONSTRUCTOR_NELTS (ctor))
(view_convert { CONSTRUCTOR_ELT (ctor, elt)->value; })
@@ -6212,15 +6212,24 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
??? Eventually allow this if the CTOR ends up constant or
uniform. */
(if (single_use (@0))
- {
- vec<constructor_elt, va_gc> *vals;
- vec_alloc (vals, count);
- for (unsigned i = 0;
- i < count && elt + i < CONSTRUCTOR_NELTS (ctor); ++i)
- CONSTRUCTOR_APPEND_ELT (vals, NULL_TREE,
- CONSTRUCTOR_ELT (ctor, elt + i)->value);
- build_constructor (type, vals);
- }))))
+ (with
+ {
+ vec<constructor_elt, va_gc> *vals;
+ vec_alloc (vals, count);
+ bool constant_p = true;
+ tree res;
+ for (unsigned i = 0;
+ i < count && elt + i < CONSTRUCTOR_NELTS (ctor); ++i)
+ {
+ tree e = CONSTRUCTOR_ELT (ctor, elt + i)->value;
+ CONSTRUCTOR_APPEND_ELT (vals, NULL_TREE, e);
+ if (!CONSTANT_CLASS_P (e))
+ constant_p = false;
+ }
+ res = (constant_p ? build_vector_from_ctor (type, vals)
+ : build_constructor (type, vals));
+ }
+ { res; })))))
/* The bitfield references a single constructor element. */
(if (k.is_constant (&const_k)
&& idx + n <= (idx / const_k + 1) * const_k)