Skip to content

Commit

Permalink
vect: Don't pass subtype to vect_widened_op_tree where not needed [PR…
Browse files Browse the repository at this point in the history
… 110142]

This patch fixes an issue introduced by
g:2f482a07365d9f4a94a56edd13b7f01b8f78b5a0, where a subtype was beeing passed
to vect_widened_op_tree, when no subtype was to be used. This lead to an
errorneous use of IFN_VEC_WIDEN_MINUS.

gcc/ChangeLog:

	PR middle-end/110142
	* tree-vect-patterns.cc (vect_recog_widen_op_pattern): Don't pass
	subtype to vect_widened_op_tree and remove subtype parameter, also
	remove superfluous overloaded function definition.
	(vect_recog_widen_plus_pattern): Remove subtype parameter and dont pass
	to call to vect_recog_widen_op_pattern.
	(vect_recog_widen_minus_pattern): Likewise.

gcc/testsuite/ChangeLog:

	* gcc.dg/vect/pr110142.c: New test.
  • Loading branch information
avieira-arm committed Jun 12, 2023
1 parent e52be60 commit 3ad0ef3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
9 changes: 9 additions & 0 deletions gcc/testsuite/gcc.dg/vect/pr110142.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* { dg-do compile } */
/* { dg-additional-options "-O3" } */
void test(short *x, unsigned short *y, int n)
{
for (int i = 0; i < n; i++)
x[i] = (y[i] - x[i]) >> 1;
}

/* { dg-final { scan-tree-dump-not "widen_minus" "vect" } } */
27 changes: 4 additions & 23 deletions gcc/tree-vect-patterns.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1405,15 +1405,14 @@ static gimple *
vect_recog_widen_op_pattern (vec_info *vinfo,
stmt_vec_info last_stmt_info, tree *type_out,
tree_code orig_code, code_helper wide_code,
bool shift_p, const char *name,
optab_subtype *subtype = NULL)
bool shift_p, const char *name)
{
gimple *last_stmt = last_stmt_info->stmt;

vect_unpromoted_value unprom[2];
tree half_type;
if (!vect_widened_op_tree (vinfo, last_stmt_info, orig_code, orig_code,
shift_p, 2, unprom, &half_type, subtype))
shift_p, 2, unprom, &half_type))

return NULL;

Expand Down Expand Up @@ -1480,20 +1479,6 @@ vect_recog_widen_op_pattern (vec_info *vinfo,
type, pattern_stmt, vecctype);
}

static gimple *
vect_recog_widen_op_pattern (vec_info *vinfo,
stmt_vec_info last_stmt_info, tree *type_out,
tree_code orig_code, internal_fn wide_ifn,
bool shift_p, const char *name,
optab_subtype *subtype = NULL)
{
combined_fn ifn = as_combined_fn (wide_ifn);
return vect_recog_widen_op_pattern (vinfo, last_stmt_info, type_out,
orig_code, ifn, shift_p, name,
subtype);
}


/* Try to detect multiplication on widened inputs, converting MULT_EXPR
to WIDEN_MULT_EXPR. See vect_recog_widen_op_pattern for details. */

Expand All @@ -1513,11 +1498,9 @@ static gimple *
vect_recog_widen_plus_pattern (vec_info *vinfo, stmt_vec_info last_stmt_info,
tree *type_out)
{
optab_subtype subtype;
return vect_recog_widen_op_pattern (vinfo, last_stmt_info, type_out,
PLUS_EXPR, IFN_VEC_WIDEN_PLUS,
false, "vect_recog_widen_plus_pattern",
&subtype);
false, "vect_recog_widen_plus_pattern");
}

/* Try to detect subtraction on widened inputs, converting MINUS_EXPR
Expand All @@ -1526,11 +1509,9 @@ static gimple *
vect_recog_widen_minus_pattern (vec_info *vinfo, stmt_vec_info last_stmt_info,
tree *type_out)
{
optab_subtype subtype;
return vect_recog_widen_op_pattern (vinfo, last_stmt_info, type_out,
MINUS_EXPR, IFN_VEC_WIDEN_MINUS,
false, "vect_recog_widen_minus_pattern",
&subtype);
false, "vect_recog_widen_minus_pattern");
}

/* Function vect_recog_ctz_ffs_pattern
Expand Down

0 comments on commit 3ad0ef3

Please sign in to comment.