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: [PR71078] x / abs(x) -> copysign (1.0, x)


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.


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