public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] vect: Vectorize via libfuncs
@ 2023-06-13 15:55 Andrew Stubbs
  2023-06-13 16:28 ` Jeff Law
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Stubbs @ 2023-06-13 15:55 UTC (permalink / raw)
  To: gcc-patches

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

This patch allows vectorization when operators are available as 
libfuncs, rather that only as insns.

This will be useful for amdgcn where we plan to vectorize loops that 
contain integer division or modulus, but don't want to generate inline 
instructions for the division algorithm every time.

The change should have not affect architectures that do not define 
vector-mode libfuncs.

OK for mainline?

Andrew

[-- Attachment #2: 230613-vect-allow-libfuncs.patch --]
[-- Type: text/plain, Size: 2031 bytes --]

vect: vectorize via libfuncs

This patch allows vectorization when the libfuncs are defined.

gcc/ChangeLog:

	* tree-vect-generic.cc: Include optabs-libfuncs.h.
	(get_compute_type): Check optab_libfunc.
	* tree-vect-stmts.cc: Include optabs-libfuncs.h.
	(vectorizable_operation): Check optab_libfunc.

diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc
index b7d4a919c55..4d784a70c0d 100644
--- a/gcc/tree-vect-generic.cc
+++ b/gcc/tree-vect-generic.cc
@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-fold.h"
 #include "gimple-match.h"
 #include "recog.h"		/* FIXME: for insn_data */
+#include "optabs-libfuncs.h"
 
 
 /* Build a ternary operation and gimplify it.  Emit code before GSI.
@@ -1714,7 +1715,8 @@ get_compute_type (enum tree_code code, optab op, tree type)
       machine_mode compute_mode = TYPE_MODE (compute_type);
       if (VECTOR_MODE_P (compute_mode))
 	{
-	  if (op && optab_handler (op, compute_mode) != CODE_FOR_nothing)
+	  if (op && (optab_handler (op, compute_mode) != CODE_FOR_nothing
+		     || optab_libfunc (op, compute_mode)))
 	    return compute_type;
 	  if (code == MULT_HIGHPART_EXPR
 	      && can_mult_highpart_p (compute_mode,
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index a7acc032d47..71a8cf2c6d4 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -56,6 +56,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-fold.h"
 #include "regs.h"
 #include "attribs.h"
+#include "optabs-libfuncs.h"
 
 /* For lang_hooks.types.type_for_mode.  */
 #include "langhooks.h"
@@ -6528,8 +6529,8 @@ vectorizable_operation (vec_info *vinfo,
                              "no optab.\n");
 	  return false;
 	}
-      target_support_p = (optab_handler (optab, vec_mode)
-			  != CODE_FOR_nothing);
+      target_support_p = (optab_handler (optab, vec_mode) != CODE_FOR_nothing
+			  || optab_libfunc (optab, vec_mode));
     }
 
   bool using_emulated_vectors_p = vect_emulated_vector_p (vectype);

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

* Re: [PATCH] vect: Vectorize via libfuncs
  2023-06-13 15:55 [PATCH] vect: Vectorize via libfuncs Andrew Stubbs
@ 2023-06-13 16:28 ` Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2023-06-13 16:28 UTC (permalink / raw)
  To: Andrew Stubbs, gcc-patches



On 6/13/23 09:55, Andrew Stubbs wrote:
> Subject:
> [PATCH] vect: Vectorize via libfuncs
> From:
> Andrew Stubbs <ams@codesourcery.com>
> Date:
> 6/13/23, 09:55
> 
> To:
> "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
> 
> 
> This patch allows vectorization when operators are available as 
> libfuncs, rather that only as insns.
> 
> This will be useful for amdgcn where we plan to vectorize loops that 
> contain integer division or modulus, but don't want to generate inline 
> instructions for the division algorithm every time.
> 
> The change should have not affect architectures that do not define 
> vector-mode libfuncs.
> 
> OK for mainline?
> 
> Andrew
> 
> 230613-vect-allow-libfuncs.patch
> 
> vect: vectorize via libfuncs
> 
> This patch allows vectorization when the libfuncs are defined.
> 
> gcc/ChangeLog:
> 
> 	* tree-vect-generic.cc: Include optabs-libfuncs.h.
> 	(get_compute_type): Check optab_libfunc.
> 	* tree-vect-stmts.cc: Include optabs-libfuncs.h.
> 	(vectorizable_operation): Check optab_libfunc.
> 
> diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc
> index b7d4a919c55..4d784a70c0d 100644
> --- a/gcc/tree-vect-generic.cc
> +++ b/gcc/tree-vect-generic.cc
> @@ -44,6 +44,7 @@ along with GCC; see the file COPYING3.  If not see
>   #include "gimple-fold.h"
>   #include "gimple-match.h"
>   #include "recog.h"		/* FIXME: for insn_data */
> +#include "optabs-libfuncs.h"
>   
>   
>   /* Build a ternary operation and gimplify it.  Emit code before GSI.
> @@ -1714,7 +1715,8 @@ get_compute_type (enum tree_code code, optab op, tree type)
>         machine_mode compute_mode = TYPE_MODE (compute_type);
>         if (VECTOR_MODE_P (compute_mode))
>   	{
> -	  if (op && optab_handler (op, compute_mode) != CODE_FOR_nothing)
> +	  if (op && (optab_handler (op, compute_mode) != CODE_FOR_nothing
> +		     || optab_libfunc (op, compute_mode)))
Formatting nit.  Bring the && down and align it under OP.  That'll 
require re-indenting the optab_libfunc call as well.

OK with that nit.

jeff

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

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13 15:55 [PATCH] vect: Vectorize via libfuncs Andrew Stubbs
2023-06-13 16:28 ` Jeff Law

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).