diff mbox series

[PATCHv2] Optab: add isnormal_optab for __builtin_isnormal

Message ID d2db5dba-85b6-4655-9af3-9d2c2e4be3a7@linux.ibm.com
State New
Headers show
Series [PATCHv2] Optab: add isnormal_optab for __builtin_isnormal | expand

Commit Message

HAO CHEN GUI May 20, 2024, 8:15 a.m. UTC
Hi,
  This patch adds an optab for __builtin_isnormal. The normal check can be
implemented on rs6000 by a single instruction. It needs an optab to be
expanded to the certain sequence of instructions.

  The subsequent patches will implement the expand on rs6000.

  Compared to previous version, the main change is to document isnormal
in md.texi.
https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649366.html

  Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no
regressions. Is this OK for trunk?

Thanks
Gui Haochen

ChangeLog
optab: Add isnormal_optab for isnormal builtin

gcc/
	* builtins.cc (interclass_mathfn_icode): Set optab to isnormal_optab
	for isnormal builtin.
	* optabs.def (isnormal_optab): New.
	* doc/md.texi (isnormal): Document.


patch.diff

Comments

HAO CHEN GUI May 27, 2024, 2:12 a.m. UTC | #1
Hi,
  Gently ping it.
https://gcc.gnu.org/pipermail/gcc-patches/2024-May/652172.html

Thanks
Gui Haochen

在 2024/5/20 16:15, HAO CHEN GUI 写道:
> Hi,
>   This patch adds an optab for __builtin_isnormal. The normal check can be
> implemented on rs6000 by a single instruction. It needs an optab to be
> expanded to the certain sequence of instructions.
> 
>   The subsequent patches will implement the expand on rs6000.
> 
>   Compared to previous version, the main change is to document isnormal
> in md.texi.
> https://gcc.gnu.org/pipermail/gcc-patches/2024-April/649366.html
> 
>   Bootstrapped and tested on x86 and powerpc64-linux BE and LE with no
> regressions. Is this OK for trunk?
> 
> Thanks
> Gui Haochen
> 
> ChangeLog
> optab: Add isnormal_optab for isnormal builtin
> 
> gcc/
> 	* builtins.cc (interclass_mathfn_icode): Set optab to isnormal_optab
> 	for isnormal builtin.
> 	* optabs.def (isnormal_optab): New.
> 	* doc/md.texi (isnormal): Document.
> 
> 
> patch.diff
> diff --git a/gcc/builtins.cc b/gcc/builtins.cc
> index b8432f84020..ccd57fce522 100644
> --- a/gcc/builtins.cc
> +++ b/gcc/builtins.cc
> @@ -2462,6 +2462,7 @@ interclass_mathfn_icode (tree arg, tree fndecl)
>      case BUILT_IN_ISFINITE:
>        builtin_optab = isfinite_optab; break;
>      case BUILT_IN_ISNORMAL:
> +      builtin_optab = isnormal_optab; break;
>      CASE_FLT_FN (BUILT_IN_FINITE):
>      case BUILT_IN_FINITED32:
>      case BUILT_IN_FINITED64:
> diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
> index 8ed70b3feea..b81b9dec18a 100644
> --- a/gcc/doc/md.texi
> +++ b/gcc/doc/md.texi
> @@ -8562,6 +8562,11 @@ This pattern is not allowed to @code{FAIL}.
>  Set operand 0 to nonzero if operand 1 is a finite floating-point
>  number and to 0 otherwise.
> 
> +@cindex @code{isnormal@var{m}2} instruction pattern
> +@item @samp{isnormal@var{m}2}
> +Set operand 0 to nonzero if operand 1 is a normal floating-point
> +number and to 0 otherwise.
> +
>  @end table
> 
>  @end ifset
> diff --git a/gcc/optabs.def b/gcc/optabs.def
> index dcd77315c2a..3c401fc0b4c 100644
> --- a/gcc/optabs.def
> +++ b/gcc/optabs.def
> @@ -353,6 +353,7 @@ OPTAB_D (hypot_optab, "hypot$a3")
>  OPTAB_D (ilogb_optab, "ilogb$a2")
>  OPTAB_D (isinf_optab, "isinf$a2")
>  OPTAB_D (isfinite_optab, "isfinite$a2")
> +OPTAB_D (isnormal_optab, "isnormal$a2")
>  OPTAB_D (issignaling_optab, "issignaling$a2")
>  OPTAB_D (ldexp_optab, "ldexp$a3")
>  OPTAB_D (log10_optab, "log10$a2")
diff mbox series

Patch

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index b8432f84020..ccd57fce522 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -2462,6 +2462,7 @@  interclass_mathfn_icode (tree arg, tree fndecl)
     case BUILT_IN_ISFINITE:
       builtin_optab = isfinite_optab; break;
     case BUILT_IN_ISNORMAL:
+      builtin_optab = isnormal_optab; break;
     CASE_FLT_FN (BUILT_IN_FINITE):
     case BUILT_IN_FINITED32:
     case BUILT_IN_FINITED64:
diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
index 8ed70b3feea..b81b9dec18a 100644
--- a/gcc/doc/md.texi
+++ b/gcc/doc/md.texi
@@ -8562,6 +8562,11 @@  This pattern is not allowed to @code{FAIL}.
 Set operand 0 to nonzero if operand 1 is a finite floating-point
 number and to 0 otherwise.

+@cindex @code{isnormal@var{m}2} instruction pattern
+@item @samp{isnormal@var{m}2}
+Set operand 0 to nonzero if operand 1 is a normal floating-point
+number and to 0 otherwise.
+
 @end table

 @end ifset
diff --git a/gcc/optabs.def b/gcc/optabs.def
index dcd77315c2a..3c401fc0b4c 100644
--- a/gcc/optabs.def
+++ b/gcc/optabs.def
@@ -353,6 +353,7 @@  OPTAB_D (hypot_optab, "hypot$a3")
 OPTAB_D (ilogb_optab, "ilogb$a2")
 OPTAB_D (isinf_optab, "isinf$a2")
 OPTAB_D (isfinite_optab, "isfinite$a2")
+OPTAB_D (isnormal_optab, "isnormal$a2")
 OPTAB_D (issignaling_optab, "issignaling$a2")
 OPTAB_D (ldexp_optab, "ldexp$a3")
 OPTAB_D (log10_optab, "log10$a2")