On Tue, 10 Nov 2015, Richard Biener wrote:

> Looks ok but I wonder if this is dead code with
> 
> (for pows (POW)
>      sqrts (SQRT)
>      cbrts (CBRT)
>  (simplify
>   (pows @0 REAL_CST@1)
>   (with {
>     const REAL_VALUE_TYPE *value = TREE_REAL_CST_PTR (@1);
>     REAL_VALUE_TYPE tmp;
>    }
>    (switch
> ...
>     /* pow(x,0.5) -> sqrt(x).  */
>     (if (flag_unsafe_math_optimizations
>          && canonicalize_math_p ()
>          && real_equal (value, &dconsthalf))
>      (sqrts @0))
> 
> also wondering here about canonicalize_math_p (), I'd expected the
> reverse transform as canonicalization.  Also wondering about
> flag_unsafe_math_optimizations (missing from the vectorizer pattern).

pow(x,0.5) -> sqrt(x) is unsafe because: pow (-0, 0.5) is specified in 
Annex F to be +0 but sqrt (-0) is -0; pow (-Inf, 0.5) is specified in 
Annex F to be +Inf, but sqrt (-Inf) is NaN with "invalid" exception 
raised.  I think it's safe in other cases (the reverse of course is not 
safe, sqrt is a fully-specified correctly-rounded IEEE operation and pow 
isn't).

-- 
Joseph S. Myers
jos...@codesourcery.com

Reply via email to