Committed, thanks Richard.

Pan

-----Original Message-----
From: Gcc-patches <gcc-patches-bounces+pan2.li=intel....@gcc.gnu.org> On Behalf 
Of Richard Sandiford via Gcc-patches
Sent: Monday, July 31, 2023 6:17 PM
To: juzhe.zh...@rivai.ai
Cc: gcc-patches@gcc.gnu.org; rguent...@suse.de
Subject: Re: [PATCH] internal-fn: Refine macro define of COND_* and COND_LEN_* 
internal functions

juzhe.zh...@rivai.ai writes:
> From: Ju-Zhe Zhong <juzhe.zh...@rivai.ai>
>
> Hi, Richard and Richi.
>
> Base on previous disscussions, we should make COND_* and COND_LEN_*
> consistent.
>
> So, this patch define these internal function together by these 2
> wrappers:
>
> #ifndef DEF_INTERNAL_COND_FN
> #define DEF_INTERNAL_COND_FN(NAME, FLAGS, OPTAB, TYPE)                        
>  \
>   DEF_INTERNAL_OPTAB_FN (COND_##NAME, FLAGS, cond_##OPTAB, cond_##TYPE)       
>  \
>   DEF_INTERNAL_OPTAB_FN (COND_LEN_##NAME, FLAGS, cond_len_##OPTAB,            
>  \
>                        cond_len_##TYPE)
> #endif
>
> #ifndef DEF_INTERNAL_SIGNED_COND_FN
> #define DEF_INTERNAL_SIGNED_COND_FN(NAME, FLAGS, SELECTOR, SIGNED_OPTAB,      
>  \
>                                   UNSIGNED_OPTAB, TYPE)                      \
>   DEF_INTERNAL_SIGNED_OPTAB_FN (COND_##NAME, FLAGS, SELECTOR,                 
>  \
>                               cond_##SIGNED_OPTAB, cond_##UNSIGNED_OPTAB,    \
>                               cond_##TYPE)                                   \
>   DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_##NAME, FLAGS, SELECTOR,             
>  \
>                               cond_len_##SIGNED_OPTAB,                       \
>                               cond_len_##UNSIGNED_OPTAB, cond_len_##TYPE)
> #endif
>
> Bootstrap and Regression on X86 passed.
> Ok for trunk ?
>
> gcc/ChangeLog:
>
>         * internal-fn.def (DEF_INTERNAL_COND_FN): New macro.
>         (DEF_INTERNAL_SIGNED_COND_FN): Ditto.
>         (COND_ADD): Remove.
>         (COND_SUB): Ditto.
>         (COND_MUL): Ditto.
>         (COND_DIV): Ditto.
>         (COND_MOD): Ditto.
>         (COND_RDIV): Ditto.
>         (COND_MIN): Ditto.
>         (COND_MAX): Ditto.
>         (COND_FMIN): Ditto.
>         (COND_FMAX): Ditto.
>         (COND_AND): Ditto.
>         (COND_IOR): Ditto.
>         (COND_XOR): Ditto.
>         (COND_SHL): Ditto.
>         (COND_SHR): Ditto.
>         (COND_FMA): Ditto.
>         (COND_FMS): Ditto.
>         (COND_FNMA): Ditto.
>         (COND_FNMS): Ditto.
>         (COND_NEG): Ditto.
>         (COND_LEN_ADD): Ditto.
>         (COND_LEN_SUB): Ditto.
>         (COND_LEN_MUL): Ditto.
>         (COND_LEN_DIV): Ditto.
>         (COND_LEN_MOD): Ditto.
>         (COND_LEN_RDIV): Ditto.
>         (COND_LEN_MIN): Ditto.
>         (COND_LEN_MAX): Ditto.
>         (COND_LEN_FMIN): Ditto.
>         (COND_LEN_FMAX): Ditto.
>         (COND_LEN_AND): Ditto.
>         (COND_LEN_IOR): Ditto.
>         (COND_LEN_XOR): Ditto.
>         (COND_LEN_SHL): Ditto.
>         (COND_LEN_SHR): Ditto.
>         (COND_LEN_FMA): Ditto.
>         (COND_LEN_FMS): Ditto.
>         (COND_LEN_FNMA): Ditto.
>         (COND_LEN_FNMS): Ditto.
>         (COND_LEN_NEG): Ditto.
>         (ADD): New macro define.
>         (SUB): Ditto.
>         (MUL): Ditto.
>         (DIV): Ditto.
>         (MOD): Ditto.
>         (RDIV): Ditto.
>         (MIN): Ditto.
>         (MAX): Ditto.
>         (FMIN): Ditto.
>         (FMAX): Ditto.
>         (AND): Ditto.
>         (IOR): Ditto.
>         (XOR): Ditto.
>         (SHL): Ditto.
>         (SHR): Ditto.
>         (FMA): Ditto.
>         (FMS): Ditto.
>         (FNMA): Ditto.
>         (FNMS): Ditto.
>         (NEG): Ditto.

OK, thanks.  (And sorry for the slow review.)

Richard

> ---
>  gcc/internal-fn.def | 123 ++++++++++++++++++++------------------------
>  1 file changed, 56 insertions(+), 67 deletions(-)
>
> diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def
> index 04f3812326e..bf6825c5d00 100644
> --- a/gcc/internal-fn.def
> +++ b/gcc/internal-fn.def
> @@ -34,10 +34,12 @@ along with GCC; see the file COPYING3.  If not see
>                                  UNSIGNED_OPTAB, TYPE)
>       DEF_INTERNAL_FLT_FN (NAME, FLAGS, OPTAB, TYPE)
>       DEF_INTERNAL_INT_FN (NAME, FLAGS, OPTAB, TYPE)
> +     DEF_INTERNAL_COND_FN (NAME, FLAGS, OPTAB, TYPE)
> +     DEF_INTERNAL_SIGNED_COND_FN (NAME, FLAGS, OPTAB, TYPE)
>  
>     where NAME is the name of the function, FLAGS is a set of
>     ECF_* flags and FNSPEC is a string describing functions fnspec.
> -   
> +
>     DEF_INTERNAL_OPTAB_FN defines an internal function that maps to a
>     direct optab.  The function should only be called with a given
>     set of types if the associated optab is available for the modes
> @@ -74,7 +76,8 @@ along with GCC; see the file COPYING3.  If not see
>  
>     - cond_len_unary: a conditional unary optab, such as cond_len_neg<mode>
>     - cond_len_binary: a conditional binary optab, such as cond_len_add<mode>
> -   - cond_len_ternary: a conditional ternary optab, such as 
> cond_len_fma_rev<mode>
> +   - cond_len_ternary: a conditional ternary optab, such as
> +   cond_len_fma_rev<mode>
>  
>     DEF_INTERNAL_SIGNED_OPTAB_FN defines an internal function that
>     maps to one of two optabs, depending on the signedness of an input.
> @@ -106,6 +109,16 @@ along with GCC; see the file COPYING3.  If not see
>     These five internal functions will require two optabs each, a SIGNED_OPTAB
>     and an UNSIGNED_OTPAB.
>  
> +   DEF_INTERNAL_COND_FN is a wrapper that defines 2 internal functions with
> +   DEF_INTERNAL_OPTAB_FN:
> +   - One is COND_* operations that are predicated by mask only. Such 
> operations
> +     make sense for both vectors and scalars.
> +   - The other is COND_LEN_* operations that are predicated by mask and len
> +     both. Such operations only make sense for vectors.
> +
> +   DEF_INTERNAL_SIGNED_COND_FN is like DEF_INTERNAL_COND_FN but defines 
> intenal
> +   functions with DEF_INTERNAL_SIGNED_OPTAB_FN.
> +
>     Each entry must have a corresponding expander of the form:
>  
>       void expand_NAME (gimple_call stmt)
> @@ -153,6 +166,24 @@ along with GCC; see the file COPYING3.  If not see
>    DEF_INTERNAL_SIGNED_OPTAB_FN (NAME ## _ODD, FLAGS, SELECTOR, SOPTAB##_odd, 
> UOPTAB##_odd, TYPE)
>  #endif
>  
> +#ifndef DEF_INTERNAL_COND_FN
> +#define DEF_INTERNAL_COND_FN(NAME, FLAGS, OPTAB, TYPE)                       
>   \
> +  DEF_INTERNAL_OPTAB_FN (COND_##NAME, FLAGS, cond_##OPTAB, cond_##TYPE)      
>   \
> +  DEF_INTERNAL_OPTAB_FN (COND_LEN_##NAME, FLAGS, cond_len_##OPTAB,           
>   \
> +                      cond_len_##TYPE)
> +#endif
> +
> +#ifndef DEF_INTERNAL_SIGNED_COND_FN
> +#define DEF_INTERNAL_SIGNED_COND_FN(NAME, FLAGS, SELECTOR, SIGNED_OPTAB,     
>   \
> +                                 UNSIGNED_OPTAB, TYPE)                      \
> +  DEF_INTERNAL_SIGNED_OPTAB_FN (COND_##NAME, FLAGS, SELECTOR,                
>   \
> +                             cond_##SIGNED_OPTAB, cond_##UNSIGNED_OPTAB,    \
> +                             cond_##TYPE)                                   \
> +  DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_##NAME, FLAGS, SELECTOR,            
>   \
> +                             cond_len_##SIGNED_OPTAB,                       \
> +                             cond_len_##UNSIGNED_OPTAB, cond_len_##TYPE)
> +#endif
> +
>  DEF_INTERNAL_OPTAB_FN (MASK_LOAD, ECF_PURE, maskload, mask_load)
>  DEF_INTERNAL_OPTAB_FN (LOAD_LANES, ECF_CONST, vec_load_lanes, load_lanes)
>  DEF_INTERNAL_OPTAB_FN (MASK_LOAD_LANES, ECF_PURE,
> @@ -220,71 +251,29 @@ DEF_INTERNAL_SIGNED_OPTAB_FN (MULHS, ECF_CONST | 
> ECF_NOTHROW, first,
>  DEF_INTERNAL_SIGNED_OPTAB_FN (MULHRS, ECF_CONST | ECF_NOTHROW, first,
>                             smulhrs, umulhrs, binary)
>  
> -DEF_INTERNAL_OPTAB_FN (COND_ADD, ECF_CONST, cond_add, cond_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_SUB, ECF_CONST, cond_sub, cond_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_MUL, ECF_CONST, cond_smul, cond_binary)
> -DEF_INTERNAL_SIGNED_OPTAB_FN (COND_DIV, ECF_CONST, first,
> -                           cond_sdiv, cond_udiv, cond_binary)
> -DEF_INTERNAL_SIGNED_OPTAB_FN (COND_MOD, ECF_CONST, first,
> -                           cond_smod, cond_umod, cond_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_RDIV, ECF_CONST, cond_sdiv, cond_binary)
> -DEF_INTERNAL_SIGNED_OPTAB_FN (COND_MIN, ECF_CONST, first,
> -                           cond_smin, cond_umin, cond_binary)
> -DEF_INTERNAL_SIGNED_OPTAB_FN (COND_MAX, ECF_CONST, first,
> -                           cond_smax, cond_umax, cond_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_FMIN, ECF_CONST, cond_fmin, cond_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_FMAX, ECF_CONST, cond_fmax, cond_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_AND, ECF_CONST | ECF_NOTHROW,
> -                    cond_and, cond_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_IOR, ECF_CONST | ECF_NOTHROW,
> -                    cond_ior, cond_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_XOR, ECF_CONST | ECF_NOTHROW,
> -                    cond_xor, cond_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_SHL, ECF_CONST | ECF_NOTHROW,
> -                    cond_ashl, cond_binary)
> -DEF_INTERNAL_SIGNED_OPTAB_FN (COND_SHR, ECF_CONST | ECF_NOTHROW, first,
> -                           cond_ashr, cond_lshr, cond_binary)
> -
> -DEF_INTERNAL_OPTAB_FN (COND_FMA, ECF_CONST, cond_fma, cond_ternary)
> -DEF_INTERNAL_OPTAB_FN (COND_FMS, ECF_CONST, cond_fms, cond_ternary)
> -DEF_INTERNAL_OPTAB_FN (COND_FNMA, ECF_CONST, cond_fnma, cond_ternary)
> -DEF_INTERNAL_OPTAB_FN (COND_FNMS, ECF_CONST, cond_fnms, cond_ternary)
> -
> -DEF_INTERNAL_OPTAB_FN (COND_NEG, ECF_CONST, cond_neg, cond_unary)
> -
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_ADD, ECF_CONST, cond_len_add, 
> cond_len_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_SUB, ECF_CONST, cond_len_sub, 
> cond_len_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_MUL, ECF_CONST, cond_len_smul, 
> cond_len_binary)
> -DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_DIV, ECF_CONST, first, cond_len_sdiv,
> -                           cond_len_udiv, cond_len_binary)
> -DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_MOD, ECF_CONST, first, cond_len_smod,
> -                           cond_len_umod, cond_len_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_RDIV, ECF_CONST, cond_len_sdiv, 
> cond_len_binary)
> -DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_MIN, ECF_CONST, first, cond_len_smin,
> -                           cond_len_umin, cond_len_binary)
> -DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_MAX, ECF_CONST, first, cond_len_smax,
> -                           cond_len_umax, cond_len_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_FMIN, ECF_CONST, cond_len_fmin, 
> cond_len_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_FMAX, ECF_CONST, cond_len_fmax, 
> cond_len_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_AND, ECF_CONST | ECF_NOTHROW, cond_len_and,
> -                    cond_len_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_IOR, ECF_CONST | ECF_NOTHROW, cond_len_ior,
> -                    cond_len_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_XOR, ECF_CONST | ECF_NOTHROW, cond_len_xor,
> -                    cond_len_binary)
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_SHL, ECF_CONST | ECF_NOTHROW, cond_len_ashl,
> -                    cond_len_binary)
> -DEF_INTERNAL_SIGNED_OPTAB_FN (COND_LEN_SHR, ECF_CONST | ECF_NOTHROW, first,
> -                           cond_len_ashr, cond_len_lshr, cond_len_binary)
> -
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_FMA, ECF_CONST, cond_len_fma, 
> cond_len_ternary)
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_FMS, ECF_CONST, cond_len_fms, 
> cond_len_ternary)
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_FNMA, ECF_CONST, cond_len_fnma,
> -                    cond_len_ternary)
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_FNMS, ECF_CONST, cond_len_fnms,
> -                    cond_len_ternary)
> -
> -DEF_INTERNAL_OPTAB_FN (COND_LEN_NEG, ECF_CONST, cond_len_neg, cond_len_unary)
> +DEF_INTERNAL_COND_FN (ADD, ECF_CONST, add, binary)
> +DEF_INTERNAL_COND_FN (SUB, ECF_CONST, sub, binary)
> +DEF_INTERNAL_COND_FN (MUL, ECF_CONST, smul, binary)
> +DEF_INTERNAL_SIGNED_COND_FN (DIV, ECF_CONST, first, sdiv, udiv, binary)
> +DEF_INTERNAL_SIGNED_COND_FN (MOD, ECF_CONST, first, smod, umod, binary)
> +DEF_INTERNAL_COND_FN (RDIV, ECF_CONST, sdiv, binary)
> +DEF_INTERNAL_SIGNED_COND_FN (MIN, ECF_CONST, first, smin, umin, binary)
> +DEF_INTERNAL_SIGNED_COND_FN (MAX, ECF_CONST, first, smax, umax, binary)
> +DEF_INTERNAL_COND_FN (FMIN, ECF_CONST, fmin, binary)
> +DEF_INTERNAL_COND_FN (FMAX, ECF_CONST, fmax, binary)
> +DEF_INTERNAL_COND_FN (AND, ECF_CONST | ECF_NOTHROW, and, binary)
> +DEF_INTERNAL_COND_FN (IOR, ECF_CONST | ECF_NOTHROW, ior, binary)
> +DEF_INTERNAL_COND_FN (XOR, ECF_CONST | ECF_NOTHROW, xor, binary)
> +DEF_INTERNAL_COND_FN (SHL, ECF_CONST | ECF_NOTHROW, ashl, binary)
> +DEF_INTERNAL_SIGNED_COND_FN (SHR, ECF_CONST | ECF_NOTHROW, first, ashr, lshr,
> +                          binary)
> +
> +DEF_INTERNAL_COND_FN (FMA, ECF_CONST, fma, ternary)
> +DEF_INTERNAL_COND_FN (FMS, ECF_CONST, fms, ternary)
> +DEF_INTERNAL_COND_FN (FNMA, ECF_CONST, fnma, ternary)
> +DEF_INTERNAL_COND_FN (FNMS, ECF_CONST, fnms, ternary)
> +
> +DEF_INTERNAL_COND_FN (NEG, ECF_CONST, neg, unary)
>  
>  DEF_INTERNAL_OPTAB_FN (RSQRT, ECF_CONST, rsqrt, unary)

Reply via email to