summaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 2f0d4ace1c1..7c9a5ec99ee 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -2427,6 +2427,27 @@ operand_equal_p (arg0, arg1, only_const)
&& REAL_VALUES_IDENTICAL (TREE_REAL_CST (arg0),
TREE_REAL_CST (arg1)));
+ case VECTOR_CST:
+ {
+ tree v1, v2;
+
+ if (TREE_CONSTANT_OVERFLOW (arg0)
+ || TREE_CONSTANT_OVERFLOW (arg1))
+ return 0;
+
+ v1 = TREE_VECTOR_CST_ELTS (arg0);
+ v2 = TREE_VECTOR_CST_ELTS (arg1);
+ while (v1 && v2)
+ {
+ if (!operand_equal_p (v1, v2, only_const))
+ return 0;
+ v1 = TREE_CHAIN (v1);
+ v2 = TREE_CHAIN (v2);
+ }
+
+ return 1;
+ }
+
case COMPLEX_CST:
return (operand_equal_p (TREE_REALPART (arg0), TREE_REALPART (arg1),
only_const)
@@ -5184,6 +5205,7 @@ fold (expr)
{
case INTEGER_CST:
case REAL_CST:
+ case VECTOR_CST:
case STRING_CST:
case COMPLEX_CST:
case CONSTRUCTOR:
@@ -7586,6 +7608,23 @@ rtl_expr_nonnegative_p (r)
return CONST_DOUBLE_HIGH (r) >= 0;
return 0;
+ case CONST_VECTOR:
+ {
+ int units, i;
+ rtx elt;
+
+ units = CONST_VECTOR_NUNITS (r);
+
+ for (i = 0; i < units; ++i)
+ {
+ elt = CONST_VECTOR_ELT (r, i);
+ if (!rtl_expr_nonnegative_p (elt))
+ return 0;
+ }
+
+ return 1;
+ }
+
case SYMBOL_REF:
case LABEL_REF:
/* These are always nonnegative. */