Message ID | 20241014061402.028DE13A51@imap1.dmz-prg2.suse.org |
---|---|
State | New |
Headers | show |
Series | middle-end/116891 - fix (negate (IFN_FNMS@3 @0 @1 @2)) -> (IFN_FMA @0 @1 @2) | expand |
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
diff --git a/gcc/match.pd b/gcc/match.pd index eff1ace87f5..b65998f201d 100644 --- 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. */