Improve tree-vect-patterns.c handling of boolean comparisons
vect_recog_bool_pattern assumed that a comparison between two booleans
should always become a comparison of vector mask types (implemented as an
XOR_EXPR). But if the booleans in question are generated as data values
(e.g. because they're loaded directly from memory), we should treat them
like ordinary integers instead, just as we do for boolean logic ops whose
operands are loaded from memory. vect_get_mask_type_for_stmt already
handled this case:
/* We may compare boolean value loaded as vector of integers.
Fix mask_type in such case. */
if (mask_type
&& !VECTOR_BOOLEAN_TYPE_P (mask_type)
&& gimple_code (stmt) == GIMPLE_ASSIGN
&& TREE_CODE_CLASS (gimple_assign_rhs_code (stmt)) == tcc_comparison)
mask_type = truth_type_for (mask_type);
and not handling it here complicated later patches.
The initial list of targets for vect_bool_cmp is deliberately conservative.
2019-11-29 Richard Sandiford <richard.sandiford@arm.com>
gcc/
* doc/sourcebuild.texi (vect_bool_cmp): Document.
* tree-vect-patterns.c (search_type_for_mask_1): If neither
operand to a boolean comparison is a natural vector mask,
handle both operands like normal integers instead.
gcc/testsuite/
* gcc.dg/vect/vect-bool-cmp-2.c: New test.
* lib/target-supports.exp (check_effective_target_vect_bool_cmp): New
effective target procedure.
From-SVN: r278847