public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* vect: Don't pass subtype to vect_widened_op_tree where not needed [PR 110142]
@ 2023-06-07 14:20 Andre Vieira (lists)
  2023-06-07 16:03 ` Richard Sandiford
  0 siblings, 1 reply; 2+ messages in thread
From: Andre Vieira (lists) @ 2023-06-07 14:20 UTC (permalink / raw)
  To: gcc-patches; +Cc: Richard Biener, Richard Sandiford

[-- Attachment #1: Type: text/plain, Size: 657 bytes --]

Hi,

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:

         * tree-vect-patterns.cc (vect_recog_widen_op_pattern): Don't 
pass subtype to
         vect_widened_op_tree and remove subtype parameter.
         (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.

[-- Attachment #2: pr110142.patch --]
[-- Type: text/plain, Size: 2863 bytes --]

diff --git a/gcc/testsuite/gcc.dg/vect/pr110142.c b/gcc/testsuite/gcc.dg/vect/pr110142.c
new file mode 100644
index 0000000000000000000000000000000000000000..a88dbe400f46a33a53649298345c24c569e2f567
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr110142.c
@@ -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" } } */
diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index dc102c919352a0328cf86eabceb3a38c41a7e4fd..599a027f9b2feb8971c1ee017b6457bc297c86c2 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -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;
 
@@ -1484,13 +1483,11 @@ 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)
+			     bool shift_p, const char *name)
 {
   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);
+				      orig_code, ifn, shift_p, name);
 }
 
 
@@ -1513,11 +1510,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
@@ -1526,11 +1521,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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: vect: Don't pass subtype to vect_widened_op_tree where not needed [PR 110142]
  2023-06-07 14:20 vect: Don't pass subtype to vect_widened_op_tree where not needed [PR 110142] Andre Vieira (lists)
@ 2023-06-07 16:03 ` Richard Sandiford
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2023-06-07 16:03 UTC (permalink / raw)
  To: Andre Vieira (lists); +Cc: gcc-patches, Richard Biener

"Andre Vieira (lists)" <andre.simoesdiasvieira@arm.com> writes:
> Hi,
>
> 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:
>
>          * tree-vect-patterns.cc (vect_recog_widen_op_pattern): Don't 
> pass subtype to
>          vect_widened_op_tree and remove subtype parameter.
>          (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.
>
> diff --git a/gcc/testsuite/gcc.dg/vect/pr110142.c b/gcc/testsuite/gcc.dg/vect/pr110142.c
> new file mode 100644
> index 0000000000000000000000000000000000000000..a88dbe400f46a33a53649298345c24c569e2f567
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/vect/pr110142.c
> @@ -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" } } */
> diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
> index dc102c919352a0328cf86eabceb3a38c41a7e4fd..599a027f9b2feb8971c1ee017b6457bc297c86c2 100644
> --- a/gcc/tree-vect-patterns.cc
> +++ b/gcc/tree-vect-patterns.cc
> @@ -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;
>  
> @@ -1484,13 +1483,11 @@ 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)
> +			     bool shift_p, const char *name)
>  {
>    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);
> +				      orig_code, ifn, shift_p, name);
>  }

I think this overload can be deleted.  An internal_fn will then
be implicitly converted to code_helper and use the overload above.

OK with that change, thanks.

Richard

>  
>  
> @@ -1513,11 +1510,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
> @@ -1526,11 +1521,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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-06-07 16:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-07 14:20 vect: Don't pass subtype to vect_widened_op_tree where not needed [PR 110142] Andre Vieira (lists)
2023-06-07 16:03 ` Richard Sandiford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).