diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-13 22:24:39 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-11-13 22:24:39 +0000 |
commit | e8253d04ce02fca1bbc6515c68abbebc7c194054 (patch) | |
tree | 74a61d6b121db6628302dca9478ae704b2173114 /gcc/fold-const.c | |
parent | d0c4444a1590f3b263a7c951458f05fbef01b34a (diff) | |
download | gcc-e8253d04ce02fca1bbc6515c68abbebc7c194054.tar.gz |
* fold-const.c (fold_convert_const): Fold changing cv-quals on
VECTOR_CST.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@230358 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 9114dec074a..ce59c488b7e 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; } |