This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC PATCH] implement fma() as builtin x87 or SSE intrinsic


> X-Original-To: geoffk@foam.wonderslug.com
> Date: Thu, 13 May 2004 14:35:57 -0600 (MDT)
> From: Roger Sayle <roger@eyesopen.com>
> Cc: gcc-patches@gcc.gnu.org
> X-OriginalArrivalTime: 13 May 2004 22:06:49.0468 (UTC) FILETIME=[96D38BC0:01C43936]
> 
> 
> On 13 May 2004, Geoff Keating wrote:
> > Actually, we should have a separate MULTPLUS rtl operation, so that
> > it can be constant-folded properly.
> 
> Indeed, though we might need a real_fma function.  I assume that to
> constant-fold "fma" its sufficient to guarantee that the multiplication
> isn't rounded (i.e. the intermediate result has twice as many mantissa
> bits as the operands) and allow the final addition to round normally.

Yes, that's sufficient, so long as the final addition is precise
before rounding even with the longer intermediate result.

> Fortunately, real.c's do_multiply returns a bool for exactly this
> eventuality.
> 
> Also would a single MULTPLUS rtx be sufficient?  I remember seeing a
> number of operand negatation variants when you improved the fmadd
> support for the rs6000.  Can these all be handled by allowing NEG
> operands to MULTPLUS or were they just canonicalizing the RTL to
> ensure that the fmadd instruction gets used?

I believe that you can handle all the possible combinations of PLUS,
MINUS, and NEG by putting NEG in the right places, like this:

(plus (mult a b) c)         -> (multplus a b c)
(minus (mult a b) c)        -> (multplus a b (neg c))
(minus c (mult a b))        -> (multplus (neg a) b c)
(minus (neg (mult a b)) c)  -> (multplus (neg a) b (neg c))

-- 
- Geoffrey Keating <geoffk@geoffk.org>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]