diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 672e384ef09..9f91878c468 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -4325,10 +4325,11 @@ verify_gimple_assign_ternary (gassign *stmt) break; case VEC_PERM_EXPR: - if (!useless_type_conversion_p (lhs_type, rhs1_type) - || !useless_type_conversion_p (lhs_type, rhs2_type)) + if (TREE_CODE (rhs1_type) != VECTOR_TYPE + || TREE_CODE (rhs2_type) != VECTOR_TYPE + || TREE_CODE (rhs3_type) != VECTOR_TYPE) { - error ("type mismatch in %qs", code_name); + error ("vector types expected in %qs", code_name); debug_generic_expr (lhs_type); debug_generic_expr (rhs1_type); debug_generic_expr (rhs2_type); @@ -4336,11 +4337,14 @@ verify_gimple_assign_ternary (gassign *stmt) return true; } - if (TREE_CODE (rhs1_type) != VECTOR_TYPE - || TREE_CODE (rhs2_type) != VECTOR_TYPE - || TREE_CODE (rhs3_type) != VECTOR_TYPE) + if (TREE_CODE (TREE_TYPE (rhs3_type)) != INTEGER_TYPE + || (TREE_CODE (rhs3) != VECTOR_CST + && (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE + (TREE_TYPE (rhs3_type))) + != GET_MODE_BITSIZE (SCALAR_TYPE_MODE + (TREE_TYPE (rhs1_type)))))) { - error ("vector types expected in %qs", code_name); + error ("invalid mask type in %qs", code_name); debug_generic_expr (lhs_type); debug_generic_expr (rhs1_type); debug_generic_expr (rhs2_type); @@ -4348,15 +4352,18 @@ verify_gimple_assign_ternary (gassign *stmt) return true; } - if (maybe_ne (TYPE_VECTOR_SUBPARTS (rhs1_type), - TYPE_VECTOR_SUBPARTS (rhs2_type)) - || maybe_ne (TYPE_VECTOR_SUBPARTS (rhs2_type), - TYPE_VECTOR_SUBPARTS (rhs3_type)) - || maybe_ne (TYPE_VECTOR_SUBPARTS (rhs3_type), - TYPE_VECTOR_SUBPARTS (lhs_type))) + /* Accept lhs = vec_perm_expr if lhs is vector length agnostic, + and has same element type as v. */ + if (!TYPE_VECTOR_SUBPARTS (lhs_type).is_constant () + && operand_equal_p (rhs1, rhs2, 0) + && TYPE_VECTOR_SUBPARTS (rhs1_type).is_constant () + && TREE_TYPE (lhs_type) == TREE_TYPE (rhs1_type)) + return false; + + if (!useless_type_conversion_p (lhs_type, rhs1_type) + || !useless_type_conversion_p (lhs_type, rhs2_type)) { - error ("vectors with different element number found in %qs", - code_name); + error ("type mismatch in %qs", code_name); debug_generic_expr (lhs_type); debug_generic_expr (rhs1_type); debug_generic_expr (rhs2_type); @@ -4364,21 +4371,21 @@ verify_gimple_assign_ternary (gassign *stmt) return true; } - if (TREE_CODE (TREE_TYPE (rhs3_type)) != INTEGER_TYPE - || (TREE_CODE (rhs3) != VECTOR_CST - && (GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE - (TREE_TYPE (rhs3_type))) - != GET_MODE_BITSIZE (SCALAR_TYPE_MODE - (TREE_TYPE (rhs1_type)))))) + if (maybe_ne (TYPE_VECTOR_SUBPARTS (rhs1_type), + TYPE_VECTOR_SUBPARTS (rhs2_type)) + || maybe_ne (TYPE_VECTOR_SUBPARTS (rhs2_type), + TYPE_VECTOR_SUBPARTS (rhs3_type)) + || maybe_ne (TYPE_VECTOR_SUBPARTS (rhs3_type), + TYPE_VECTOR_SUBPARTS (lhs_type))) { - error ("invalid mask type in %qs", code_name); + error ("vectors with different element number found in %qs", + code_name); debug_generic_expr (lhs_type); debug_generic_expr (rhs1_type); debug_generic_expr (rhs2_type); debug_generic_expr (rhs3_type); return true; } - return false; case SAD_EXPR: