From: Tamar Christina Date: Thu, 9 Nov 2023 14:00:20 +0000 (+0000) Subject: ifcvt: Add support for conditional copysign X-Git-Tag: basepoints/gcc-15~4854 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f30ecd8050444fb902ab66b4600c590908861fdf;p=thirdparty%2Fgcc.git ifcvt: Add support for conditional copysign This adds a masked variant of copysign. Nothing very exciting just the general machinery to define and use a new masked IFN. Bootstrapped Regtested on aarch64-none-linux-gnu and no issues. Note: This patch is part of a testseries and tests for it are added in the AArch64 patch that adds supports for the optab. gcc/ChangeLog: PR tree-optimization/109154 * internal-fn.def (COPYSIGN): New. * match.pd (UNCOND_BINARY, COND_BINARY): Map IFN_COPYSIGN to IFN_COND_COPYSIGN. * optabs.def (cond_copysign_optab, cond_len_copysign_optab): New. --- diff --git a/gcc/internal-fn.def b/gcc/internal-fn.def index 7f0e37596157..ec72b3b0d9d3 100644 --- a/gcc/internal-fn.def +++ b/gcc/internal-fn.def @@ -270,6 +270,7 @@ 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 (COPYSIGN, ECF_CONST, copysign, 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) diff --git a/gcc/match.pd b/gcc/match.pd index 5928acbb14e2..f559bfa4f2b3 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -95,14 +95,14 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) plus minus mult trunc_div trunc_mod rdiv min max - IFN_FMIN IFN_FMAX + IFN_FMIN IFN_FMAX IFN_COPYSIGN bit_and bit_ior bit_xor lshift rshift) (define_operator_list COND_BINARY IFN_COND_ADD IFN_COND_SUB IFN_COND_MUL IFN_COND_DIV IFN_COND_MOD IFN_COND_RDIV IFN_COND_MIN IFN_COND_MAX - IFN_COND_FMIN IFN_COND_FMAX + IFN_COND_FMIN IFN_COND_FMAX IFN_COND_COPYSIGN IFN_COND_AND IFN_COND_IOR IFN_COND_XOR IFN_COND_SHL IFN_COND_SHR) (define_operator_list COND_LEN_BINARY @@ -110,7 +110,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) IFN_COND_LEN_MUL IFN_COND_LEN_DIV IFN_COND_LEN_MOD IFN_COND_LEN_RDIV IFN_COND_LEN_MIN IFN_COND_LEN_MAX - IFN_COND_LEN_FMIN IFN_COND_LEN_FMAX + IFN_COND_LEN_FMIN IFN_COND_LEN_FMAX IFN_COND_LEN_COPYSIGN IFN_COND_LEN_AND IFN_COND_LEN_IOR IFN_COND_LEN_XOR IFN_COND_LEN_SHL IFN_COND_LEN_SHR) diff --git a/gcc/optabs.def b/gcc/optabs.def index 8d5ceeb87104..07c06ba8cbbb 100644 --- a/gcc/optabs.def +++ b/gcc/optabs.def @@ -256,6 +256,7 @@ OPTAB_D (cond_fms_optab, "cond_fms$a") OPTAB_D (cond_fnma_optab, "cond_fnma$a") OPTAB_D (cond_fnms_optab, "cond_fnms$a") OPTAB_D (cond_neg_optab, "cond_neg$a") +OPTAB_D (cond_copysign_optab, "cond_copysign$F$a") OPTAB_D (cond_one_cmpl_optab, "cond_one_cmpl$a") OPTAB_D (cond_len_add_optab, "cond_len_add$a") OPTAB_D (cond_len_sub_optab, "cond_len_sub$a") @@ -281,6 +282,7 @@ OPTAB_D (cond_len_fms_optab, "cond_len_fms$a") OPTAB_D (cond_len_fnma_optab, "cond_len_fnma$a") OPTAB_D (cond_len_fnms_optab, "cond_len_fnms$a") OPTAB_D (cond_len_neg_optab, "cond_len_neg$a") +OPTAB_D (cond_len_copysign_optab, "cond_len_copysign$F$a") OPTAB_D (cond_len_one_cmpl_optab, "cond_len_one_cmpl$a") OPTAB_D (vcond_mask_len_optab, "vcond_mask_len_$a") OPTAB_D (cmov_optab, "cmov$a6")