From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 77392 invoked by alias); 11 Aug 2019 12:46:24 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 77384 invoked by uid 89); 11 Aug 2019 12:46:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,GIT_PATCH_1,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=five X-HELO: mail-ed1-f45.google.com Received: from mail-ed1-f45.google.com (HELO mail-ed1-f45.google.com) (209.85.208.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 11 Aug 2019 12:46:22 +0000 Received: by mail-ed1-f45.google.com with SMTP id h8so13035571edv.7 for ; Sun, 11 Aug 2019 05:46:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/+WNypx4iJ+mCZE3nIycbB9GL4o4Jf1107rvjeqyXos=; b=m7XBtqDRKrCpx8GznvPqmr/MJF8CCxGlVE8i5Ta6j9mA0JNNU6GuDAOShoVSpAvQbC 5V3XwO4luxFMCAzphjcPHT+X5SA5jreqjwgIU6TyezXV/2sm15sbACdmG52nsOzcR92i Jf2Mf8q7Mq7vRmk3KmP6x922n8LPh+Yri/L/L5Yt8PRFrMuQtHnF9REhwiPENu+GR85u eXDRJDdc36SzQuSTZUD6TdiymRAvMJnJTfR17wVCCPRPJrBnZJuoTX+r7uZPS4ZkmGH9 co7fhKySMsTmJekvF8v2+2Lp37FukBzJVpoz7naURiRJmiZPayOlL8XhCNY8g6h6llGr Dghw== MIME-Version: 1.0 References: <87sgqnx4i6.fsf@oldenburg2.str.redhat.com> <20190731144722.GS31406@gate.crashing.org> <20190808200514.GL31406@gate.crashing.org> <20190810164600.GT31406@gate.crashing.org> <20190811071955.GV31406@gate.crashing.org> In-Reply-To: <20190811071955.GV31406@gate.crashing.org> From: Tejas Joshi Date: Sun, 11 Aug 2019 12:46:00 -0000 Message-ID: Subject: Re: Expansion of narrowing math built-ins into power instructions To: gcc@gcc.gnu.org Cc: Martin Jambor , hubicka@ucw.cz, segher@kernel.crashing.org, joseph@codesourcery.com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00086.txt.bz2 Hello. > with it, but first get DP->SP (fadd) working? Can you please review what have I have been trying and facing the issues on patch : Thanks, Tejas On Sun, 11 Aug 2019 at 12:50, Segher Boessenkool wrote: > > Hi Tejas, > > On Sun, Aug 11, 2019 at 10:34:26AM +0530, Tejas Joshi wrote: > > > As far as I understand that flag should set the behaviour of the fadd > > > function, not the __builtin_fadd one. So I don't know. > > > > According to ISO/IEC TS 18661, I am supposed to implement the fadd > > variants for folding and expand them inline, that take double and long > > double as arguments and return > > addition in appropriate narrower type, float and double. As far as I > > know, we use __builtin_ to call the internal functions? I do not know > > which the only fadd function is. > > See the manual, section "Other Built-in Functions Provided by GCC": > > @opindex fno-builtin > GCC includes built-in versions of many of the functions in the standard > C library. These functions come in two forms: one whose names start with > the @code{__builtin_} prefix, and the other without. Both forms have the > same type (including prototype), the same address (when their address is > taken), and the same meaning as the C library functions even if you specify > the @option{-fno-builtin} option @pxref{C Dialect Options}). Many of these > functions are only optimized in certain cases; if they are not optimized in > a particular case, a call to the library function is emitted. > > > > double precision one. But instead you want to add two double precision > > > numbers, producing a single precision one? The fadds instruction fits > > > > Yes. > > > > > well to that, but you'll have to check exactly how the fadd() function > > > should behave with respect to rounding and exceptions and the like. > > I read 18661-1 now... and yup, "fadds" will work fine, and there are > no complications like this as far as I see. > > For QP to either DP or SP, you can do round-to-odd followed by one of the > conversion instructions. The ISA manual describes this; I can help you > with it, but first get DP->SP (fadd) working? > > For the non-QP long doubles we have... There is the option of using DP > for it, which isn't standard-compliant, many other archs have it too, > and it is simple anyway, because you have all code for operations > already. You can mostly just ignore this option. > > For double-double... Well firstly, double-double is on the way out, so > adding new features to it is pretty useless? Just ignore it unless you > have time left, I'd say. > > > In Joseph's initial mail that describes what should be carried out in > > the course of project, about rounding and exceptions. I have strictly > > followed this description for my folding patch : > > > > * The narrowing functions, e.g. fadd, faddl, daddl, are a bit different > > from most other built-in math.h functions because the return type is > > different from the argument types. You could start by adding them to > > builtins.def similarly to roundeven (with new macros to handle adding such > > functions for relevant pairs of _FloatN, _FloatNx types). These functions > > could be folded for constant arguments only if the result is exact, or if > > -fno-rounding-math -fno-trapping-math (and -fno-math-errno if the result > > involves overflow / underflow). > > For Power, all five basic operations (add, sub, mul, div, fma) work fine > wrt rounding mode if using the fadds etc. insns, for DP->SP. All > exceptions work as expected, except maybe underflow and overflow, but > 18661 doesn't require much at all for those anyway :-) > > > Segher