https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115710

--- Comment #10 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #9)
> (In reply to Andrew Pinski from comment #8)
> > I wonder if we could also add:
> > +/* cabs(x+0i) or cabs(0+xi) -> abs(x).  */
> > +(simplify
> > + (CABS (complex:c @0 real_zerop@1))
> > + (abs @0))
> > 
> > 
> > + /* cabs(x+xi) -> fabs(x)*sqrt(2).  */
> > + (simplify
> > +  (CABS (complex @0 @0))
> > +  (mult (abs @0) { build_real_truncate (type, dconst_sqrt2 ()); })))
> > 
> > 
> > to the lowering part.
> > 
> > let me look into doing that but it will be 3rd part to the patch series.
> > Since we should have this info already ...
> 
> This is needed to get the same code generation as before for:
> ```
> double f(double a, double c)
> {
>   _Complex double b = a;
>   b+= c;
>   return __builtin_cabs(b);
> }
> ```

And the other testcase that matters here:
```
double f(double a, double c)
{
  _Complex double d = __builtin_complex (a, a);
  d+=__builtin_complex(1.0, 1.0);
  return __builtin_cabs(d);
}

```

Reply via email to