diff options
author | Jakub Jelinek <jakub@redhat.com> | 2012-09-28 12:18:57 +0000 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2012-09-28 12:18:57 +0000 |
commit | f3f39b462aa2b7636feaa9e9db083d253d72f170 (patch) | |
tree | ed78d34a78eb25b4804dcb75880712505ce51a5f /gcc/fold-const.c | |
parent | d94d906385fb0c27cc1082c6f19488aa288cf35a (diff) |
PR tree-optimization/54713
* fold-const.c (vec_cst_ctor_to_array): Give up if vector CONSTRUCTOR
has vector elements.
(fold_ternary_loc) <case BIT_FIELD_REF>: Likewise.
* tree-vect-generic.c (vector_element): Don't rely on CONSTRUCTOR elts
indexes. Use BIT_FIELD_REF if CONSTRUCTOR has vector elements.
(lower_vec_perm): Use NULL_TREE CONSTRUCTOR indexes.
* gcc.c-torture/compile/pr54713-1.c: New test.
* gcc.c-torture/compile/pr54713-2.c: New test.
* gcc.c-torture/compile/pr54713-3.c: New test.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@191826 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index ce522357ee2..fd0075c4971 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9559,7 +9559,7 @@ vec_cst_ctor_to_array (tree arg, tree *elts) constructor_elt *elt; FOR_EACH_VEC_ELT (constructor_elt, CONSTRUCTOR_ELTS (arg), i, elt) - if (i >= nelts) + if (i >= nelts || TREE_CODE (TREE_TYPE (elt->value)) == VECTOR_TYPE) return false; else elts[i] = elt->value; @@ -14030,22 +14030,35 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type, unsigned i; if (CONSTRUCTOR_NELTS (arg0) == 0) return build_constructor (type, NULL); - vals = VEC_alloc (constructor_elt, gc, n); - for (i = 0; i < n && idx + i < CONSTRUCTOR_NELTS (arg0); - ++i) - CONSTRUCTOR_APPEND_ELT (vals, NULL_TREE, - CONSTRUCTOR_ELT - (arg0, idx + i)->value); - return build_constructor (type, vals); + if (TREE_CODE (TREE_TYPE (CONSTRUCTOR_ELT (arg0, + 0)->value)) + != VECTOR_TYPE) + { + vals = VEC_alloc (constructor_elt, gc, n); + for (i = 0; + i < n && idx + i < CONSTRUCTOR_NELTS (arg0); + ++i) + CONSTRUCTOR_APPEND_ELT (vals, NULL_TREE, + CONSTRUCTOR_ELT + (arg0, idx + i)->value); + return build_constructor (type, vals); + } } } else if (n == 1) { if (TREE_CODE (arg0) == VECTOR_CST) return VECTOR_CST_ELT (arg0, idx); - else if (idx < CONSTRUCTOR_NELTS (arg0)) - return CONSTRUCTOR_ELT (arg0, idx)->value; - return build_zero_cst (type); + else if (CONSTRUCTOR_NELTS (arg0) == 0) + return build_zero_cst (type); + else if (TREE_CODE (TREE_TYPE (CONSTRUCTOR_ELT (arg0, + 0)->value)) + != VECTOR_TYPE) + { + if (idx < CONSTRUCTOR_NELTS (arg0)) + return CONSTRUCTOR_ELT (arg0, idx)->value; + return build_zero_cst (type); + } } } } |