Commit ce19a482 by Richard Sandiford Committed by Richard Sandiford

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
parent 9d50a6a7
2019-11-29 Richard Sandiford <richard.sandiford@arm.com>
* 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.
2019-11-29 Richard Biener <rguenther@suse.de> 2019-11-29 Richard Biener <rguenther@suse.de>
* tree-ssa-sccvn.c (vn_walk_cb_data::push_partial_def): Bail * tree-ssa-sccvn.c (vn_walk_cb_data::push_partial_def): Bail
...@@ -1522,6 +1522,10 @@ Target does not support a vector add instruction on @code{int}. ...@@ -1522,6 +1522,10 @@ Target does not support a vector add instruction on @code{int}.
@item vect_no_bitwise @item vect_no_bitwise
Target does not support vector bitwise instructions. Target does not support vector bitwise instructions.
@item vect_bool_cmp
Target supports comparison of @code{bool} vectors for at least one
vector length.
@item vect_char_add @item vect_char_add
Target supports addition of @code{char} vectors for at least one Target supports addition of @code{char} vectors for at least one
vector length. vector length.
......
2019-11-29 Richard Sandiford <richard.sandiford@arm.com>
* gcc.dg/vect/vect-bool-cmp-2.c: New test.
* lib/target-supports.exp (check_effective_target_vect_bool_cmp): New
effective target procedure.
2019-11-29 Tobias Burnus <tobias@codesourcery.com> 2019-11-29 Tobias Burnus <tobias@codesourcery.com>
* fortran.dg/goacc/common-block-3.f90: Check that unused common-block * fortran.dg/goacc/common-block-3.f90: Check that unused common-block
......
/* { dg-do compile } */
void
f (_Bool *restrict x, _Bool *restrict y)
{
for (int i = 0; i < 128; ++i)
x[i] = x[i] == y[i];
}
/* { dg-final { scan-tree-dump "loop vectorized" "vect" { target vect_bool_cmp } } } */
...@@ -5749,6 +5749,16 @@ proc check_effective_target_vect_bswap { } { ...@@ -5749,6 +5749,16 @@ proc check_effective_target_vect_bswap { } {
|| [istarget amdgcn-*-*] }}] || [istarget amdgcn-*-*] }}]
} }
# Return 1 if the target supports comparison of bool vectors for at
# least one vector length.
proc check_effective_target_vect_bool_cmp { } {
return [check_cached_effective_target_indexed vect_bool_cmp {
expr { [istarget i?86-*-*] || [istarget x86_64-*-*]
|| [istarget aarch64*-*-*]
|| [is-effective-target arm_neon] }}]
}
# Return 1 if the target supports addition of char vectors for at least # Return 1 if the target supports addition of char vectors for at least
# one vector length. # one vector length.
......
...@@ -3944,7 +3944,8 @@ search_type_for_mask_1 (tree var, vec_info *vinfo, ...@@ -3944,7 +3944,8 @@ search_type_for_mask_1 (tree var, vec_info *vinfo,
vinfo, cache); vinfo, cache);
if (!res || (res2 && TYPE_PRECISION (res) > TYPE_PRECISION (res2))) if (!res || (res2 && TYPE_PRECISION (res) > TYPE_PRECISION (res2)))
res = res2; res = res2;
break; if (res)
break;
} }
comp_vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (rhs1)); comp_vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (rhs1));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment