aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorMarc Glisse <marc.glisse@inria.fr>2012-10-23 14:51:22 +0200
committerMarc Glisse <glisse@gcc.gnu.org>2012-10-23 12:51:22 +0000
commita8dcc458896307fb03bb3b8c56c33a1b860837c4 (patch)
tree9d49e15eb24b4681bee36a4cb27693dddf91dcd8 /gcc/fold-const.c
parent053223551fd7253097117744fcafccd28c8941c0 (diff)
downloadgcc-a8dcc458896307fb03bb3b8c56c33a1b860837c4.zip
gcc-a8dcc458896307fb03bb3b8c56c33a1b860837c4.tar.gz
gcc-a8dcc458896307fb03bb3b8c56c33a1b860837c4.tar.bz2
tree-ssa-forwprop.c (forward_propagate_into_cond): Handle vectors.
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. From-SVN: r192711
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 053b3f5..e3e4151 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.