On Mon, Oct 14, 2024 at 08:14:01AM +0200, Richard Biener wrote:
> Transforming -fma (-a, b, -c) to fma (a, b, c) is only valid when
> not rounding towards -inf or +inf as the sign of the multiplication
> changes.
>
> Bootstrap and regtest running on x86_64-unknown-linux-gnu, OK?
>
> Richard.
>
> PR middle-end/116891
> * match.pd ((negate (IFN_FNMS@3 @0 @1 @2)) -> (IFN_FMA @0 @1 @2)):
> Only enable for !HONOR_SIGN_DEPENDENT_ROUNDING.
Guess it would be nice to have a testcase which FAILs without the patch and
PASSes with it, but it can be added later.
So ok.
> --- a/gcc/match.pd
> +++ b/gcc/match.pd
> @@ -9482,7 +9482,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
> (IFN_FMA @0 @1 @2))
> (simplify
> (negate (IFN_FNMS@3 @0 @1 @2))
> - (if (single_use (@3))
> + (if (!HONOR_SIGN_DEPENDENT_ROUNDING (type) && single_use (@3))
> (IFN_FMA @0 @1 @2))))
>
> /* CLZ simplifications. */
> --
> 2.43.0
Jakub