public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] MATCH: Optimize COND_ADD reduction pattern
@ 2023-09-26  8:25 Juzhe-Zhong
  2023-09-26  9:41 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Juzhe-Zhong @ 2023-09-26  8:25 UTC (permalink / raw)
  To: gcc-patches; +Cc: richard.sandiford, rguenther, Juzhe-Zhong

Current COND_ADD reduction pattern can't optimize floating-point vector.
As Richard suggested: https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631336.html
Allow COND_ADD reduction pattern to optimize floating-point vector.

Bootstrap and Regression is running.

Ok for trunk if tests pass ?

gcc/ChangeLog:

	* match.pd: Optimize COND_ADD reduction pattern.

---
 gcc/match.pd | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 5061c19e086..398beaebd27 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -8863,8 +8863,10 @@ and,
 
    c = mask1 && mask2 ? d + b : d.  */
 (simplify
-  (IFN_COND_ADD @0 @1 (vec_cond @2 @3 integer_zerop) @1)
-   (IFN_COND_ADD (bit_and @0 @2) @1 @3 @1))
+  (IFN_COND_ADD @0 @1 (vec_cond @2 @3 zerop@4) @1)
+   (if (ANY_INTEGRAL_TYPE_P (type)
+	|| fold_real_zero_addition_p (type, NULL_TREE, @4, 0))
+   (IFN_COND_ADD (bit_and @0 @2) @1 @3 @1)))
 
 /* Detect simplication for a conditional length reduction where
 
-- 
2.36.3


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

* Re: [PATCH] MATCH: Optimize COND_ADD reduction pattern
  2023-09-26  8:25 [PATCH] MATCH: Optimize COND_ADD reduction pattern Juzhe-Zhong
@ 2023-09-26  9:41 ` Richard Biener
  2023-09-26  9:59   ` juzhe.zhong
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2023-09-26  9:41 UTC (permalink / raw)
  To: Juzhe-Zhong; +Cc: gcc-patches, richard.sandiford

On Tue, 26 Sep 2023, Juzhe-Zhong wrote:

> Current COND_ADD reduction pattern can't optimize floating-point vector.
> As Richard suggested: https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631336.html
> Allow COND_ADD reduction pattern to optimize floating-point vector.
> 
> Bootstrap and Regression is running.
> 
> Ok for trunk if tests pass ?

I just wondered about fixed point - zerop seems to also allow
fixed_zerop.  Maybe do

 if (ANY_INTEGRAL_TYPE_P (type)
     || (FLOAT_TYPE_P (type)
         && fold_real_zero_addition_p (type, NULL_TREE, @4, 0)))

(also for the other patch) to avoid touching the fixed point case.

Richard.

> gcc/ChangeLog:
> 
> 	* match.pd: Optimize COND_ADD reduction pattern.
> 
> ---
>  gcc/match.pd | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/gcc/match.pd b/gcc/match.pd
> index 5061c19e086..398beaebd27 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -8863,8 +8863,10 @@ and,
>  
>     c = mask1 && mask2 ? d + b : d.  */
>  (simplify
> -  (IFN_COND_ADD @0 @1 (vec_cond @2 @3 integer_zerop) @1)
> -   (IFN_COND_ADD (bit_and @0 @2) @1 @3 @1))
> +  (IFN_COND_ADD @0 @1 (vec_cond @2 @3 zerop@4) @1)
> +   (if (ANY_INTEGRAL_TYPE_P (type)
> +	|| fold_real_zero_addition_p (type, NULL_TREE, @4, 0))
> +   (IFN_COND_ADD (bit_and @0 @2) @1 @3 @1)))
>  
>  /* Detect simplication for a conditional length reduction where
>  
> 

-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)

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

* Re: Re: [PATCH] MATCH: Optimize COND_ADD reduction pattern
  2023-09-26  9:41 ` Richard Biener
@ 2023-09-26  9:59   ` juzhe.zhong
  0 siblings, 0 replies; 3+ messages in thread
From: juzhe.zhong @ 2023-09-26  9:59 UTC (permalink / raw)
  To: rguenther; +Cc: gcc-patches, richard.sandiford

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

Address comments:

V3 COND_LEN_ADD:https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631350.html 
V2 COND_ADD: https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631352.html 

Thanks.


juzhe.zhong@rivai.ai
 
From: Richard Biener
Date: 2023-09-26 17:41
To: Juzhe-Zhong
CC: gcc-patches; richard.sandiford
Subject: Re: [PATCH] MATCH: Optimize COND_ADD reduction pattern
On Tue, 26 Sep 2023, Juzhe-Zhong wrote:
 
> Current COND_ADD reduction pattern can't optimize floating-point vector.
> As Richard suggested: https://gcc.gnu.org/pipermail/gcc-patches/2023-September/631336.html
> Allow COND_ADD reduction pattern to optimize floating-point vector.
> 
> Bootstrap and Regression is running.
> 
> Ok for trunk if tests pass ?
 
I just wondered about fixed point - zerop seems to also allow
fixed_zerop.  Maybe do
 
if (ANY_INTEGRAL_TYPE_P (type)
     || (FLOAT_TYPE_P (type)
         && fold_real_zero_addition_p (type, NULL_TREE, @4, 0)))
 
(also for the other patch) to avoid touching the fixed point case.
 
Richard.
 
> gcc/ChangeLog:
> 
> * match.pd: Optimize COND_ADD reduction pattern.
> 
> ---
>  gcc/match.pd | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/gcc/match.pd b/gcc/match.pd
> index 5061c19e086..398beaebd27 100644
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -8863,8 +8863,10 @@ and,
>  
>     c = mask1 && mask2 ? d + b : d.  */
>  (simplify
> -  (IFN_COND_ADD @0 @1 (vec_cond @2 @3 integer_zerop) @1)
> -   (IFN_COND_ADD (bit_and @0 @2) @1 @3 @1))
> +  (IFN_COND_ADD @0 @1 (vec_cond @2 @3 zerop@4) @1)
> +   (if (ANY_INTEGRAL_TYPE_P (type)
> + || fold_real_zero_addition_p (type, NULL_TREE, @4, 0))
> +   (IFN_COND_ADD (bit_and @0 @2) @1 @3 @1)))
>  
>  /* Detect simplication for a conditional length reduction where
>  
> 
 
-- 
Richard Biener <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
 

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-26  8:25 [PATCH] MATCH: Optimize COND_ADD reduction pattern Juzhe-Zhong
2023-09-26  9:41 ` Richard Biener
2023-09-26  9:59   ` juzhe.zhong

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