On Fri, 26 Jun 2015, Richard Biener wrote:
OK. The reason I was being paranoid was that I couldn't see anywhere
where we enforced that the vector condition in a VEC_COND had to have
the same element width as the values being selected.
We don't require that indeed.
tree-cfg.c
only checks that rhs2 and rhs3 are compatible with the result.
There doesn't seem to be any checking of rhs1 vs. the other types.
So I wasn't sure whether anything stopped us from, e.g., comparing two
V4HIs and using the result to select between two V4SIs.
Nothing does (or should).
The documentation patch you approved in
https://gcc.gnu.org/ml/gcc-patches/2012-10/msg01109.html says something
different. If it is really wrong, could you fix it?
Hmm, that simplifies things.
On the other hand, vectors of bools could be (I haven't thought about it
much) nice to have, especially for avx512 (and at least one other arch,
maybe sparc).
It would be nice if these constraints would also be checked in the
gimple verifier...
This passed bootstrap+testsuite on powerpc64le-unknown-linux-gnu.
2015-06-29 Marc Glisse <marc.gli...@inria.fr>
* tree-cfg.c (verify_gimple_assign_ternary) <VEC_COND_EXPR>: Check
the first argument.
--
Marc Glisse
Index: gcc/tree-cfg.c
===================================================================
--- gcc/tree-cfg.c (revision 225104)
+++ gcc/tree-cfg.c (working copy)
@@ -4001,8 +4001,22 @@
}
break;
+ case VEC_COND_EXPR:
+ if (!VECTOR_INTEGER_TYPE_P (rhs1_type)
+ || TYPE_SIGN (rhs1_type) != SIGNED
+ || TYPE_SIZE (rhs1_type) != TYPE_SIZE (lhs_type)
+ || TYPE_VECTOR_SUBPARTS (rhs1_type)
+ != TYPE_VECTOR_SUBPARTS (lhs_type))
+ {
+ error ("the first argument of a VEC_COND_EXPR must be of a signed "
+ "integral vector type of the same size and number of "
+ "elements as the result");
+ debug_generic_expr (lhs_type);
+ debug_generic_expr (rhs1_type);
+ return true;
+ }
+ /* Fallthrough. */
case COND_EXPR:
- case VEC_COND_EXPR:
if (!useless_type_conversion_p (lhs_type, rhs2_type)
|| !useless_type_conversion_p (lhs_type, rhs3_type))
{