diff options
author | Richard Biener <rguenther@suse.de> | 2015-10-30 12:18:34 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2015-10-30 12:18:34 +0000 |
commit | 7524f419ae7935594e7ec85daf7cdf736a835b04 (patch) | |
tree | 3269624dbefe5c8fadf56f8111a9ab750dc67096 /gcc/tree.c | |
parent | 04e3481107705d98ecd442657ee0b6b594e53b78 (diff) | |
download | gcc-7524f419ae7935594e7ec85daf7cdf736a835b04.zip gcc-7524f419ae7935594e7ec85daf7cdf736a835b04.tar.gz gcc-7524f419ae7935594e7ec85daf7cdf736a835b04.tar.bz2 |
gimple-fold.c (fold_gimple_assign): Do not dispatch to fold () on single RHSs.
2015-10-30 Richard Biener <rguenther@suse.de>
* gimple-fold.c (fold_gimple_assign): Do not dispatch to
fold () on single RHSs. Allow CONSTRUCTORS with trailing
zeros to be folded to VECTOR_CSTs.
* tree.c (build_vector_from_ctor): Handle VECTOR_CST elements.
* fold-const.c (fold): Use build_vector_from_ctor.
From-SVN: r229574
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -1729,13 +1729,19 @@ tree build_vector_from_ctor (tree type, vec<constructor_elt, va_gc> *v) { tree *vec = XALLOCAVEC (tree, TYPE_VECTOR_SUBPARTS (type)); - unsigned HOST_WIDE_INT idx; + unsigned HOST_WIDE_INT idx, pos = 0; tree value; FOR_EACH_CONSTRUCTOR_VALUE (v, idx, value) - vec[idx] = value; + { + if (TREE_CODE (value) == VECTOR_CST) + for (unsigned i = 0; i < VECTOR_CST_NELTS (value); ++i) + vec[pos++] = VECTOR_CST_ELT (value, i); + else + vec[pos++] = value; + } for (; idx < TYPE_VECTOR_SUBPARTS (type); ++idx) - vec[idx] = build_zero_cst (TREE_TYPE (type)); + vec[pos++] = build_zero_cst (TREE_TYPE (type)); return build_vector (type, vec); } |