Improve tree-vect-patterns.c handling of boolean comparisons
authorRichard Sandiford <richard.sandiford@arm.com>
Fri, 29 Nov 2019 14:47:20 +0000 (14:47 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Fri, 29 Nov 2019 14:47:20 +0000 (14:47 +0000)
commitce19a4822794992097deab96bf15bf78ff481ea1
tree00093167689e7899ae3168a0fbc8f61e557973ef
parent9d50a6a78509b42b3c2b2264da1a0d2c4b151d66
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
gcc/ChangeLog
gcc/doc/sourcebuild.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/vect-bool-cmp-2.c [new file with mode: 0644]
gcc/testsuite/lib/target-supports.exp
gcc/tree-vect-patterns.c