> Note that this is not safe with -fsignaling-nans, so needs to be disabled
> for that option (if there isn't already logic somewhere with that effect),
> because the extend will convert a signaling NaN to quiet (raising
> "invalid"), but copysign won't, so this transformation could result in a
> signaling NaN being wrongly returned when the original code would never
> have returned a signaling NaN.
>
> --
> Joseph S. Myers
> jos...@codesourcery.com

Bootstrapped and regtested on x86_64-linux-gnu{-m32,}.
Ok for trunk?

gcc/ChangeLog

        * match.pd
        (Simplifcation (trunc)copysign((extend)a, (extend)b) to
        .COPYSIGN (a, b)): Add !flag_signaling_nans.
---
 gcc/match.pd | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index fb1065dc0e6..d6a8dd0dd20 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -6176,6 +6176,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (simplify
   (convert (copysigns (convert@2 @0) (convert @1)))
    (if (optimize
+       && !flag_signaling_nans
        && types_match (type, TREE_TYPE (@0))
        && types_match (type, TREE_TYPE (@1))
        && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@2))
-- 
2.18.1

Reply via email to