public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tejas Joshi <tejasjoshi9673@gmail.com>
To: gcc@gcc.gnu.org
Cc: Martin Jambor <mjambor@suse.cz>,
	hubicka@ucw.cz, segher@kernel.crashing.org,
		joseph@codesourcery.com
Subject: Re: Expansion of narrowing math built-ins into power instructions
Date: Sat, 10 Aug 2019 10:24:00 -0000	[thread overview]
Message-ID: <CACMrGjB1UmfKuTCwGLi5oTapr4EM-JxbfVGr_GvwucWwfg0oYg@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.21.1908082304570.5719@digraph.polyomino.org.uk>

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

Hello.
I have been trying to write a basic pattern taking all the suggestions
you both have mentioned. The same patch is attached here, but I cannot
see call to :

float
foo (double x, double y)
{
    return __builtin_fadd (x, y);
}
being expanded to any instruction, at least a simple one, using
-fno-builtin-fadd (and also -mhard-float?). It always stays "bl fadd".
What am I missing here?

> (POWER8 and later) on.  (The result if OE=1 or UE=1 is undefined).  (See
> 4.3.5.1 in the ISA).

4.3.5.1 in the ISA says that single precision arithmetic instructions
perform operation in double format and coerces the result in single
format. Can fadd be considered as this type of instruction or do I
need to perform add in DFmode and then use "instruction provided to
explicitly convert double format operand in FPR to single format."?

Thanks,
Tejas


On Fri, 9 Aug 2019 at 04:39, Joseph Myers <joseph@codesourcery.com> wrote:
>
> On Thu, 8 Aug 2019, Segher Boessenkool wrote:
>
> > These current patterns all take the same mode for all inputs and outputs
> > (that's what <mode>3 indicates, say, fadddf3).  You will need to define
> > something that takes two SFs in and produces a DF.  That cannot really
>
> For example, md.texi describes standard patterns such as mulhisi3 that
> multiply two HImode values and produce an SImode result (widening integer
> multiply).
>
> Using a similar naming pattern, you might have a pattern adddfsf3 that
> multiplies two DFmode values and produces an SFmode result (or you could
> call it something like add_truncdfsf3 if you wish to emphasise the
> truncation involved, for example).  Similarly addtfsf3 that multiplies
> TFmode and produces an SFmode result, and so on.  Of course these names
> need documenting (and you need corresponding RTL for them to generate that
> distinguishes the fused add+truncate from the different RTL for separate
> addition and truncation with double rounding).  In cases where long double
> and double have the same mode, the daddl function should use the existing
> adddf3 pattern.
>
> --
> Joseph S. Myers
> joseph@codesourcery.com

[-- Attachment #2: fadd-md.diff --]
[-- Type: text/x-patch, Size: 1380 bytes --]

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 4ef1993..e4bfc4a 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -4652,6 +4652,21 @@
   [(set_attr "type" "fp")
    (set_attr "isa" "*,<Fisa>")])
 
+(define_expand "add_truncdfsf3"
+  [(set (float_extend:DF (match_operand:SF 0 "gpc_reg_operand"))
+	(plus:DF (match_operand:DF 1 "gpc_reg_operand")
+		 (match_operand:DF 2 "gpc_reg_operand")))]
+  "TARGET_HARD_FLOAT"
+  "")
+
+(define_insn "*add_truncdfsf3_fpr"
+  [(set (float_extend:DF (match_operand:SF 0 "gpc_reg_operand" "=<Ff>"))
+	(plus:DF (match_operand:DF 1 "gpc_reg_operand" "%<Ff>")
+		 (match_operand:DF 2 "gpc_reg_operand" "<Ff>")))]
+  "TARGET_HARD_FLOAT"
+  "fadd %0,%1,%2"
+  [(set_attr "type" "fp")])
+
 (define_expand "sub<mode>3"
   [(set (match_operand:SFDF 0 "gpc_reg_operand")
 	(minus:SFDF (match_operand:SFDF 1 "gpc_reg_operand")
diff --git a/gcc/optabs.def b/gcc/optabs.def
index 4ffd0f3..45be794 100644
--- a/gcc/optabs.def
+++ b/gcc/optabs.def
@@ -67,6 +67,7 @@ OPTAB_CD(sfixtrunc_optab, "fix_trunc$F$b$I$a2")
 OPTAB_CD(ufixtrunc_optab, "fixuns_trunc$F$b$I$a2")
 
 /* Misc optabs that use two modes; model them as "conversions".  */
+OPTAB_CD(fadd_optab, "add_trunc$b$a3")
 OPTAB_CD(smul_widen_optab, "mul$b$a3")
 OPTAB_CD(umul_widen_optab, "umul$b$a3")
 OPTAB_CD(usmul_widen_optab, "usmul$b$a3")

  reply	other threads:[~2019-08-10 10:24 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-29 17:37 Martin Jambor
2019-07-29 18:40 ` Segher Boessenkool
2019-07-30 19:47   ` Joseph Myers
2019-07-30  9:20 ` Florian Weimer
2019-07-30 19:49   ` Joseph Myers
2019-07-31  6:47     ` Tejas Joshi
2019-07-31 14:47       ` Segher Boessenkool
2019-08-08 18:39         ` Tejas Joshi
2019-08-08 20:05           ` Segher Boessenkool
2019-08-08 23:09             ` Joseph Myers
2019-08-10 10:24               ` Tejas Joshi [this message]
2019-08-10 16:46                 ` Segher Boessenkool
2019-08-11  4:58                   ` Tejas Joshi
2019-08-11  7:20                     ` Segher Boessenkool
2019-08-11 12:46                       ` Tejas Joshi
2019-08-11 16:59                 ` Segher Boessenkool
2019-08-12 17:25                   ` Tejas Joshi
2019-08-12 17:55                     ` Segher Boessenkool
2019-08-12 21:20                       ` Joseph Myers
2019-08-12 21:52                         ` Segher Boessenkool
2019-08-14  6:15                           ` Tejas Joshi
2019-08-14  7:21                             ` Segher Boessenkool
2019-08-14 16:11                               ` Joseph Myers
2019-08-14 20:21                                 ` Segher Boessenkool
2019-08-14 20:23                                   ` Joseph Myers
2019-08-14 21:00                                     ` Segher Boessenkool
2019-08-15  9:52                                       ` Tejas Joshi
2019-08-15 12:47                                         ` Richard Sandiford
2019-08-15 13:55                                           ` Tejas Joshi
2019-08-15 18:45                                           ` Segher Boessenkool
2019-08-16 10:23                                             ` Richard Sandiford
2019-08-17  5:40                                               ` Tejas Joshi
2019-08-17  8:21                                                 ` Richard Sandiford
2019-08-19 10:46                                                   ` Tejas Joshi
2019-08-19 13:07                                                   ` Segher Boessenkool
2019-08-20  7:41                                                     ` Richard Sandiford
2019-08-20 12:11                                                       ` Segher Boessenkool
2019-08-20 12:59                                                         ` Richard Sandiford
2019-08-20 13:46                                                           ` Segher Boessenkool
2019-08-20 14:43                                                             ` Richard Sandiford
2019-08-20 15:12                                                               ` Richard Sandiford
2019-08-20 19:42                                                               ` Segher Boessenkool
2019-08-21 17:20                                                                 ` Tejas Joshi
2019-08-21 18:28                                                                   ` Segher Boessenkool
2019-08-21 19:17                                                                     ` Segher Boessenkool
2019-08-22  3:33                                                                       ` Tejas Joshi
2019-08-22  6:25                                                                         ` Segher Boessenkool
2019-08-22  7:57                                                                           ` Tejas Joshi
2019-08-22  9:56                                                                             ` Segher Boessenkool
2019-08-23 17:17                                                                               ` Martin Jambor
2019-08-23 19:13                                                                                 ` Segher Boessenkool
2019-08-24  9:53                                                                                 ` Richard Sandiford
2019-08-25 13:55                                                                                   ` Tejas Joshi
2019-08-25 16:47                                                                                     ` Segher Boessenkool
2019-08-26  7:07                                                                                       ` Tejas Joshi
2019-08-26  7:42                                                                                         ` Segher Boessenkool
2019-08-30 19:12                                                                                           ` Tejas Joshi
2019-08-30 20:35                                                                                             ` Segher Boessenkool
2019-09-02  3:19                                                                                               ` Tejas Joshi
2019-09-02 11:30                                                                                                 ` Segher Boessenkool
2019-08-26 13:23                                                                                   ` Martin Jambor
2019-08-20 16:04                                                         ` Joseph Myers
2019-08-15 18:54                                         ` Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CACMrGjB1UmfKuTCwGLi5oTapr4EM-JxbfVGr_GvwucWwfg0oYg@mail.gmail.com \
    --to=tejasjoshi9673@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=joseph@codesourcery.com \
    --cc=mjambor@suse.cz \
    --cc=segher@kernel.crashing.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).