On Tue, 4 Oct 2016, Marc Glisse wrote:

> On Tue, 4 Oct 2016, Richard Biener wrote:
> 
> > Possibly.  Though then for FP we also want - abs (a) -> copysign (a, -1).
> 
> I thought this might fix PR 62055, but at least on x86_64, we generate much
> worse code for copysign(,-1) than for -abs :-(

I would have expected copysign(,-1) to be a simple IOR ...

double foo (double x)
{
  return __builtin_copysign (x, -1.);
}

foo:
.LFB0:
        .cfi_startproc
        movsd   .LC0(%rip), %xmm1
        movapd  %xmm1, %xmm2
        andpd   .LC2(%rip), %xmm2
        andpd   .LC1(%rip), %xmm0
        orpd    %xmm2, %xmm0
        ret

ICK. -fabs (x) yields

foo:
.LFB0:
        .cfi_startproc
        andpd  .LC0(%rip), %xmm0
        xorpd  .LC1(%rip), %xmm0
        ret

I expected a simple orpd .LC0(%rip), %xmm0 ...

Richard.

Reply via email to