diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2012-10-30 13:56:47 +0100 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2012-10-30 12:56:47 +0000 |
commit | 2e2e628b24501fc8362ec1797c331091e702f5a5 (patch) | |
tree | 43e796b6b41df8a8571952bfe92a803c5aec082f | |
parent | 4fda1ad1dcd40178e001a11b6cd82bce5eed7260 (diff) | |
download | gcc-2e2e628b24501fc8362ec1797c331091e702f5a5.tar.gz |
fold-const.c (fold_binary_op_with_conditional_arg): Handle vectors.
2012-10-30 Marc Glisse <marc.glisse@inria.fr>
* fold-const.c (fold_binary_op_with_conditional_arg): Handle vectors.
(fold_binary_loc): call it for VEC_COND_EXPR.
From-SVN: r192986
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/fold-const.c | 17 |
2 files changed, 18 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 467bec3c3c7..8cf846bbd62 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2012-10-30 Marc Glisse <marc.glisse@inria.fr> + + * fold-const.c (fold_binary_op_with_conditional_arg): Handle vectors. + (fold_binary_loc): call it for VEC_COND_EXPR. + 2012-10-30 James Greenhalgh <james.greenhalgh@arm.com> Tejas Belagod <tejas.belagod@arm.com> diff --git a/gcc/fold-const.c b/gcc/fold-const.c index e3e4151ae60..0caca2e5794 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -5959,8 +5959,10 @@ fold_binary_op_with_conditional_arg (location_t loc, tree test, true_value, false_value; tree lhs = NULL_TREE; tree rhs = NULL_TREE; + enum tree_code cond_code = COND_EXPR; - if (TREE_CODE (cond) == COND_EXPR) + if (TREE_CODE (cond) == COND_EXPR + || TREE_CODE (cond) == VEC_COND_EXPR) { test = TREE_OPERAND (cond, 0); true_value = TREE_OPERAND (cond, 1); @@ -5981,6 +5983,9 @@ fold_binary_op_with_conditional_arg (location_t loc, false_value = constant_boolean_node (false, testtype); } + if (TREE_CODE (TREE_TYPE (test)) == VECTOR_TYPE) + cond_code = VEC_COND_EXPR; + /* This transformation is only worthwhile if we don't have to wrap ARG in a SAVE_EXPR and the operation can be simplified on at least one of the branches once its pushed inside the COND_EXPR. */ @@ -6011,7 +6016,7 @@ fold_binary_op_with_conditional_arg (location_t loc, if (!TREE_CONSTANT (arg) && !TREE_CONSTANT (lhs) && !TREE_CONSTANT (rhs)) return NULL_TREE; - return fold_build3_loc (loc, COND_EXPR, type, test, lhs, rhs); + return fold_build3_loc (loc, cond_code, type, test, lhs, rhs); } @@ -9871,7 +9876,9 @@ fold_binary_loc (location_t loc, tem); } - if (TREE_CODE (arg0) == COND_EXPR || COMPARISON_CLASS_P (arg0)) + if (TREE_CODE (arg0) == COND_EXPR + || TREE_CODE (arg0) == VEC_COND_EXPR + || COMPARISON_CLASS_P (arg0)) { tem = fold_binary_op_with_conditional_arg (loc, code, type, op0, op1, arg0, arg1, @@ -9880,7 +9887,9 @@ fold_binary_loc (location_t loc, return tem; } - if (TREE_CODE (arg1) == COND_EXPR || COMPARISON_CLASS_P (arg1)) + if (TREE_CODE (arg1) == COND_EXPR + || TREE_CODE (arg1) == VEC_COND_EXPR + || COMPARISON_CLASS_P (arg1)) { tem = fold_binary_op_with_conditional_arg (loc, code, type, op0, op1, arg1, arg0, |