Hi. I've been working on transition of cond expressions to match.pd. With my changes I noticed there's one wrong pattern that leads to:
Transforming _6 > _7 & _6 < _7 into 0 ... /home/marxin/Programming/gcc/gcc/testsuite/c-c++-common/vector-compare-3.c:20:1: error: the first argument of a ‘vec_cond_expr’ must be of a boolean vector type of the same number of elements as the result 20 | g (v4i *x, v4i const *y, v4i *z, v4i *t) | ^ vector(4) int _Bool _9 = VEC_COND_EXPR <0, { -1, -1, -1, -1 }, { 0, 0, 0, 0 }>; which is wrong. Proper simlification is: Transforming _6 > _7 & _6 < _7 into { 0, 0, 0, 0 } Patch can bootstrap on x86_64-linux-gnu and survives regression tests. Ready to be installed? Thanks, Martin gcc/ChangeLog: 2019-09-06 Martin Liska <mli...@suse.cz> * match.pd: For vector types, take type from a vector argument of the expression. --- gcc/match.pd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gcc/match.pd b/gcc/match.pd index 1d13543a615..66e3c25ee87 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -3769,7 +3769,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) (bit_and:c (test1 @0 @1) (test2 @0 @1)) (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) || VECTOR_INTEGER_TYPE_P (TREE_TYPE (@0))) - { constant_boolean_node (false, type); }))) + { constant_boolean_node (false, INTEGRAL_TYPE_P (TREE_TYPE (@0)) ? type : TREE_TYPE (@0)); }))) /* A & (2**N - 1) <= 2**K - 1 -> A & (2**N - 2**K) == 0 A & (2**N - 1) > 2**K - 1 -> A & (2**N - 2**K) != 0