This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PR71078] x / abs(x) -> copysign (1.0, x)
- From: Richard Biener <rguenther at suse dot de>
- To: Prathamesh Kulkarni <prathamesh dot kulkarni at linaro dot org>
- Cc: Joseph Myers <joseph at codesourcery dot com>, Richard Sandiford <richard dot sandiford at arm dot com>, gcc Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 1 Aug 2016 09:47:42 +0200 (CEST)
- Subject: Re: [PR71078] x / abs(x) -> copysign (1.0, x)
- Authentication-results: sourceware.org; auth=none
- References: <CAAgBjM=E8-YEMumvRN0PwD1t1xxZb7iLQGhg2tOh+95gnaN5kA@mail.gmail.com> <alpine.LSU.2.11.1607261359460.30444@t29.fhfr.qr> <8760rsa5lz.fsf@e105548-lin.cambridge.arm.com> <alpine.DEB.2.20.1607292126090.24174@digraph.polyomino.org.uk> <CAAgBjMn73aCK=Dwy5QCqumZDbnZo80W4YumJWkJz=yH1n9=Kyg@mail.gmail.com>
On Mon, 1 Aug 2016, Prathamesh Kulkarni wrote:
> On 30 July 2016 at 02:57, Joseph Myers <joseph@codesourcery.com> wrote:
> > On Tue, 26 Jul 2016, Richard Sandiford wrote:
> >
> >> (which are really just extended tree codes). I suppose copysign is
> >> a special case since we can always open code it, but in general we
> >> shouldn't fall back to something that could generate a call.
> >
> > We can't always open code copysign (IBM long double, see PR 58797).
> Hi,
> Thanks for pointing that out.
> The attached patch doesn't transform x/abs(x) -> copysign(1.0, x)
> for long double.
> OK for trunk ?
I don't think so - the pattern is as much a canonicalization as an
optimization. If the target cannot expand copysign then the
middle-end expander should try an alternative like the a / abs(x)
form. Though if copysign cannot be open-coded then I don't see
how abs can be opencoded (which basically is copysign (1.0, x)).
Richard.