[PR71078] x / abs(x) -> copysign (1.0, x)

Richard Biener rguenther@suse.de
Mon Aug 1 07:47:00 GMT 2016

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)).


More information about the Gcc-patches mailing list