aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2015-11-13 17:24:39 -0500
committerJason Merrill <jason@gcc.gnu.org>2015-11-13 17:24:39 -0500
commit9514e74fcd529835a8963f91e12e1ee853149095 (patch)
tree74a61d6b121db6628302dca9478ae704b2173114 /gcc
parente45639f3bd6fcc2f28256ef332dc7cc11c83acce (diff)
downloadgcc-9514e74fcd529835a8963f91e12e1ee853149095.zip
gcc-9514e74fcd529835a8963f91e12e1ee853149095.tar.gz
gcc-9514e74fcd529835a8963f91e12e1ee853149095.tar.bz2
fold-const.c (fold_convert_const): Fold changing cv-quals on VECTOR_CST.
* fold-const.c (fold_convert_const): Fold changing cv-quals on VECTOR_CST. From-SVN: r230358
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog3
-rw-r--r--gcc/fold-const.c19
-rw-r--r--gcc/tree.def2
3 files changed, 23 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index eeec887..74fa2d4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,8 @@
2015-11-13 Jason Merrill <jason@redhat.com>
+ * fold-const.c (fold_convert_const): Fold changing cv-quals on
+ VECTOR_CST.
+
* hash-map.h (hash_map::empty): New.
2015-11-13 Nathan Sidwell <nathan@codesourcery.com>
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 9114dec..ce59c48 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2095,6 +2095,25 @@ fold_convert_const (enum tree_code code, tree type, tree arg1)
else if (TREE_CODE (arg1) == REAL_CST)
return fold_convert_const_fixed_from_real (type, arg1);
}
+ else if (TREE_CODE (type) == VECTOR_TYPE)
+ {
+ if (TREE_CODE (arg1) == VECTOR_CST
+ && TYPE_VECTOR_SUBPARTS (type) == VECTOR_CST_NELTS (arg1))
+ {
+ int len = TYPE_VECTOR_SUBPARTS (type);
+ tree elttype = TREE_TYPE (type);
+ tree *v = XALLOCAVEC (tree, len);
+ for (int i = 0; i < len; ++i)
+ {
+ tree elt = VECTOR_CST_ELT (arg1, i);
+ tree cvt = fold_convert_const (code, elttype, elt);
+ if (cvt == NULL_TREE)
+ return NULL_TREE;
+ v[i] = cvt;
+ }
+ return build_vector (type, v);
+ }
+ }
return NULL_TREE;
}
diff --git a/gcc/tree.def b/gcc/tree.def
index 41064a8..44e5a5e 100644
--- a/gcc/tree.def
+++ b/gcc/tree.def
@@ -303,7 +303,7 @@ DEFTREECODE (FIXED_CST, "fixed_cst", tcc_constant, 0)
whose contents are other constant nodes. */
DEFTREECODE (COMPLEX_CST, "complex_cst", tcc_constant, 0)
-/* Contents are in TREE_VECTOR_CST_ELTS field. */
+/* Contents are in VECTOR_CST_ELTS field. */
DEFTREECODE (VECTOR_CST, "vector_cst", tcc_constant, 0)
/* Contents are TREE_STRING_LENGTH and the actual contents of the string. */