diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2012-10-23 12:51:22 +0000 |
---|---|---|
committer | Marc Glisse <marc.glisse@inria.fr> | 2012-10-23 12:51:22 +0000 |
commit | ce9f42e555129a8dd1080710c4007642eae1808b (patch) | |
tree | 9d49e15eb24b4681bee36a4cb27693dddf91dcd8 /gcc/fold-const.c | |
parent | 302dc0d9faa493b85db673a41e4645f15ce6bdd8 (diff) |
2012-10-23 Marc Glisse <marc.glisse@inria.fr>
gcc/
* tree-ssa-forwprop.c (forward_propagate_into_cond): Handle vectors.
* fold-const.c (fold_relational_const): Handle VECTOR_CST.
* doc/generic.texi (VEC_COND_EXPR): Document current policy.
gcc/testsuite/
* gcc.dg/tree-ssa/foldconst-6.c: New testcase.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@192711 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 053b3f524c5..e3e4151ae60 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -16130,6 +16130,31 @@ fold_relational_const (enum tree_code code, tree type, tree op0, tree op1) return NULL_TREE; } + if (TREE_CODE (op0) == VECTOR_CST && TREE_CODE (op1) == VECTOR_CST) + { + unsigned count = VECTOR_CST_NELTS (op0); + tree *elts = XALLOCAVEC (tree, count); + gcc_assert (VECTOR_CST_NELTS (op1) == count + && TYPE_VECTOR_SUBPARTS (type) == count); + + for (unsigned i = 0; i < count; i++) + { + tree elem_type = TREE_TYPE (type); + tree elem0 = VECTOR_CST_ELT (op0, i); + tree elem1 = VECTOR_CST_ELT (op1, i); + + tree tem = fold_relational_const (code, elem_type, + elem0, elem1); + + if (tem == NULL_TREE) + return NULL_TREE; + + elts[i] = build_int_cst (elem_type, integer_zerop (tem) ? 0 : -1); + } + + return build_vector (type, elts); + } + /* From here on we only handle LT, LE, GT, GE, EQ and NE. To compute GT, swap the arguments and do LT. |