public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH v1] LoongArch: Adjust the vector cost model for better performance
@ 2023-09-18  9:23 Li Wei
  2023-09-18  9:54 ` chenglulu
  0 siblings, 1 reply; 2+ messages in thread
From: Li Wei @ 2023-09-18  9:23 UTC (permalink / raw)
  To: gcc-patches; +Cc: xry111, i, xuchenghua, chenglulu, Li Wei

gcc/ChangeLog:

	* config/loongarch/loongarch.cc (loongarch_builtin_vectorization_cost):
---
 gcc/config/loongarch/loongarch.cc | 21 ++++++++++++++-------
 1 file changed, 14 insertions(+), 7 deletions(-)

diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
index 845fad5a8e8..d24fc30570d 100644
--- a/gcc/config/loongarch/loongarch.cc
+++ b/gcc/config/loongarch/loongarch.cc
@@ -3860,17 +3860,18 @@ loongarch_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
   switch (type_of_cost)
     {
       case scalar_stmt:
-      case scalar_load:
       case vector_stmt:
-      case vector_load:
       case vec_to_scalar:
       case scalar_to_vec:
-      case cond_branch_not_taken:
       case vec_promote_demote:
       case scalar_store:
-      case vector_store:
+      case scalar_load:
 	return 1;
 
+      case vector_store:
+      case vector_load:
+	return 2;
+
       case vec_perm:
 	return LASX_SUPPORTED_MODE_P (mode)
 	  && !LSX_SUPPORTED_MODE_P (mode) ? 2 : 1;
@@ -3881,14 +3882,20 @@ loongarch_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
 
       case unaligned_store:
       case vector_scatter_store:
-	return 10;
+	return 5;
 
       case cond_branch_taken:
-	return 3;
+	return 4;
+
+      case cond_branch_not_taken:
+	return 2;
 
       case vec_construct:
 	elements = TYPE_VECTOR_SUBPARTS (vectype);
-	return elements / 2 + 1;
+	if (ISA_HAS_LASX)
+	  return elements + 1;
+	else
+	  return elements;
 
       default:
 	gcc_unreachable ();
-- 
2.31.1


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

* Re: [PATCH v1] LoongArch: Adjust the vector cost model for better performance
  2023-09-18  9:23 [PATCH v1] LoongArch: Adjust the vector cost model for better performance Li Wei
@ 2023-09-18  9:54 ` chenglulu
  0 siblings, 0 replies; 2+ messages in thread
From: chenglulu @ 2023-09-18  9:54 UTC (permalink / raw)
  To: Li Wei, gcc-patches; +Cc: xry111, i, xuchenghua

Hi,liwei:

  It is best to add a test case. If the test case is really difficult to 
extract, then enrich the description information.

Thanks!

在 2023/9/18 下午5:23, Li Wei 写道:
> gcc/ChangeLog:
>
> 	* config/loongarch/loongarch.cc (loongarch_builtin_vectorization_cost):
> ---
>   gcc/config/loongarch/loongarch.cc | 21 ++++++++++++++-------
>   1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/gcc/config/loongarch/loongarch.cc b/gcc/config/loongarch/loongarch.cc
> index 845fad5a8e8..d24fc30570d 100644
> --- a/gcc/config/loongarch/loongarch.cc
> +++ b/gcc/config/loongarch/loongarch.cc
> @@ -3860,17 +3860,18 @@ loongarch_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
>     switch (type_of_cost)
>       {
>         case scalar_stmt:
> -      case scalar_load:
>         case vector_stmt:
> -      case vector_load:
>         case vec_to_scalar:
>         case scalar_to_vec:
> -      case cond_branch_not_taken:
>         case vec_promote_demote:
>         case scalar_store:
> -      case vector_store:
> +      case scalar_load:
>   	return 1;
>   
> +      case vector_store:
> +      case vector_load:
> +	return 2;
> +
>         case vec_perm:
>   	return LASX_SUPPORTED_MODE_P (mode)
>   	  && !LSX_SUPPORTED_MODE_P (mode) ? 2 : 1;
> @@ -3881,14 +3882,20 @@ loongarch_builtin_vectorization_cost (enum vect_cost_for_stmt type_of_cost,
>   
>         case unaligned_store:
>         case vector_scatter_store:
> -	return 10;
> +	return 5;
>   
>         case cond_branch_taken:
> -	return 3;
> +	return 4;
> +
> +      case cond_branch_not_taken:
> +	return 2;
>   
>         case vec_construct:
>   	elements = TYPE_VECTOR_SUBPARTS (vectype);
> -	return elements / 2 + 1;
> +	if (ISA_HAS_LASX)
> +	  return elements + 1;
> +	else
> +	  return elements;
>   
>         default:
>   	gcc_unreachable ();


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

end of thread, other threads:[~2023-09-18  9:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-18  9:23 [PATCH v1] LoongArch: Adjust the vector cost model for better performance Li Wei
2023-09-18  9:54 ` chenglulu

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