fold-const.c (const_binop): Combine two VECTOR_CST under operation CODE to produce a new one.
2009-04-08 Bingfeng Mei <bmei@broadcom.com> * fold-const.c (const_binop): Combine two VECTOR_CST under operation CODE to produce a new one. Add a prototype to use fold_convert_const From-SVN: r145731
This commit is contained in:
parent
40a14772d9
commit
d1d1c602b8
@ -1,3 +1,8 @@
|
||||
2009-04-08 Bingfeng Mei <bmei@broadcom.com>
|
||||
|
||||
* fold-const.c (const_binop): Combine two VECTOR_CST under operation
|
||||
CODE to produce a new one. Add a prototype to use fold_convert_const
|
||||
|
||||
2009-04-08 Danny Smith <dannysmith@users.sourceforge.net>
|
||||
|
||||
PR bootstrap/39660
|
||||
|
@ -141,6 +141,7 @@ static bool reorder_operands_p (const_tree, const_tree);
|
||||
static tree fold_negate_const (tree, tree);
|
||||
static tree fold_not_const (tree, tree);
|
||||
static tree fold_relational_const (enum tree_code, tree, tree, tree);
|
||||
static tree fold_convert_const (enum tree_code, tree, tree);
|
||||
|
||||
|
||||
/* We know that A1 + B1 = SUM1, using 2's complement arithmetic and ignoring
|
||||
@ -1998,6 +1999,50 @@ const_binop (enum tree_code code, tree arg1, tree arg2, int notrunc)
|
||||
return build_complex (type, real, imag);
|
||||
}
|
||||
|
||||
if (TREE_CODE (arg1) == VECTOR_CST)
|
||||
{
|
||||
tree type = TREE_TYPE(arg1);
|
||||
int count = TYPE_VECTOR_SUBPARTS (type), i;
|
||||
tree elements1, elements2, list = NULL_TREE;
|
||||
|
||||
if(TREE_CODE(arg2) != VECTOR_CST)
|
||||
return NULL_TREE;
|
||||
|
||||
elements1 = TREE_VECTOR_CST_ELTS (arg1);
|
||||
elements2 = TREE_VECTOR_CST_ELTS (arg2);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
tree elem1, elem2, elem;
|
||||
|
||||
/* The trailing elements can be empty and should be treated as 0 */
|
||||
if(!elements1)
|
||||
elem1 = fold_convert_const (NOP_EXPR, TREE_TYPE (type), integer_zero_node);
|
||||
else
|
||||
{
|
||||
elem1 = TREE_VALUE(elements1);
|
||||
elements1 = TREE_CHAIN (elements1);
|
||||
}
|
||||
|
||||
if(!elements2)
|
||||
elem2 = fold_convert_const (NOP_EXPR, TREE_TYPE (type), integer_zero_node);
|
||||
else
|
||||
{
|
||||
elem2 = TREE_VALUE(elements2);
|
||||
elements2 = TREE_CHAIN (elements2);
|
||||
}
|
||||
|
||||
elem = const_binop (code, elem1, elem2, notrunc);
|
||||
|
||||
/* It is possible that const_binop cannot handle the given
|
||||
code and return NULL_TREE */
|
||||
if(elem == NULL_TREE)
|
||||
return NULL_TREE;
|
||||
|
||||
list = tree_cons (NULL_TREE, elem, list);
|
||||
}
|
||||
return build_vector(type, nreverse(list));
|
||||
}
|
||||
return NULL_TREE;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user