Commit 6805bd36 by Marc Glisse Committed by Marc Glisse

re PR tree-optimization/56790 (VEC_COND_EXPR not constant folded)

2013-04-03  Marc Glisse  <marc.glisse@inria.fr>

	PR tree-optimization/56790
gcc/
	* fold-const.c (fold_ternary_loc) <VEC_COND_EXPR>: Add constant folding.

gcc/testsuite/
	* g++.dg/ext/pr56790-1.C: New testcase.

From-SVN: r197395
parent da694a77
2013-04-03 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/56790
* fold-const.c (fold_ternary_loc) <VEC_COND_EXPR>: Add constant folding.
2013-04-03 Marc Glisse <marc.glisse@inria.fr>
* simplify-rtx.c (simplify_binary_operation_1) <VEC_SELECT>:
Handle VEC_MERGE.
(simplify_ternary_operation) <VEC_MERGE>: Use unsigned HOST_WIDE_INT
......
......@@ -13924,6 +13924,29 @@ fold_ternary_loc (location_t loc, enum tree_code code, tree type,
return pedantic_omit_one_operand_loc (loc, type, arg1, arg2);
if (integer_zerop (arg0))
return pedantic_omit_one_operand_loc (loc, type, arg2, arg1);
if ((TREE_CODE (arg1) == VECTOR_CST
|| TREE_CODE (arg1) == CONSTRUCTOR)
&& (TREE_CODE (arg2) == VECTOR_CST
|| TREE_CODE (arg2) == CONSTRUCTOR))
{
unsigned int nelts = TYPE_VECTOR_SUBPARTS (type), i;
unsigned char *sel = XALLOCAVEC (unsigned char, nelts);
gcc_assert (nelts == VECTOR_CST_NELTS (arg0));
for (i = 0; i < nelts; i++)
{
tree val = VECTOR_CST_ELT (arg0, i);
if (integer_all_onesp (val))
sel[i] = i;
else if (integer_zerop (val))
sel[i] = nelts + i;
else /* Currently unreachable. */
return NULL_TREE;
}
tree t = fold_vec_perm (type, arg1, arg2, sel);
if (t != NULL_TREE)
return t;
}
}
if (operand_equal_p (arg1, op2, 0))
......
2013-04-03 Marc Glisse <marc.glisse@inria.fr>
PR tree-optimization/56790
* g++.dg/ext/pr56790-1.C: New testcase.
2013-04-03 Marc Glisse <marc.glisse@inria.fr>
* gcc.target/i386/merge-1.c: New testcase.
* gcc.target/i386/avx2-vpblendd128-1.c: Make it non-trivial.
......
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-ccp1" } */
typedef long vec __attribute__ ((vector_size (2 * sizeof (long))));
vec f (void)
{
vec a = { 5, 7 };
vec b = { 11, 13 };
vec m = { -1, 0 };
return m ? a : b;
}
/* { dg-final { scan-tree-dump "{ 5, 13 }" "ccp1" } } */
/* { dg-final { scan-tree-dump-not "VEC_COND_EXPR" "ccp1" } } */
/* { dg-final { cleanup-tree-dump "ccp1" } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment