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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Tamar Christina from comment #2)
> Note that __builtin_sqrt is correctly marked as trapping. So this doesn't
> vectorize.
> 
> void f (float *c, int n)
> {
>     for (int i = 0; i < n; i++)
>       c[i] = __builtin_sqrt (c[i]);
> }
> 
> unless at -Ofast.

This will produce the non conditional SQRT though:
```
void f (float *__restrict c, float *__restrict d, int n)
{
    for (int i = 0; i < n; i++)
    {
      if (d[i] > 1000)
        c[i] = __builtin_sqrt (c[i]);
    }
}

```

at `-O2 -fno-math-errno`.

Hmm,

#define ATTR_MATHFN_FPROUNDING_ERRNO (flag_errno_math ? \
        (flag_rounding_math ? ATTR_ERRNOPURE_NOTHROW_LEAF_LIST \
         : ATTR_ERRNOCONST_NOTHROW_LEAF_LIST) : ATTR_MATHFN_FPROUNDING)

And fortran does:
  opts->x_flag_errno_math = 0;



So the issue is a bit more complex. Maybe ATTR_MATHFN_FPROUNDING_ERRNO  is
wrong for sqrt{,f,ll}.

Reply via email to