Thanks for your suggestions. I have modified accordingly. Attached please find the adapted patch. Bootstrap and tested on aarch64 Linux platform. Does the v2 patch look batter?
diff --git a/gcc/combine.c b/gcc/combine.c index cff76cd3303..ad8a385fc48 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -6643,7 +6643,8 @@ simplify_if_then_else (rtx x) /* Look for MIN or MAX. */ - if ((! FLOAT_MODE_P (mode) || flag_unsafe_math_optimizations) + if ((! FLOAT_MODE_P (mode) + || (!HONOR_NANS (mode) && !HONOR_SIGNED_ZEROS (mode))) && comparison_p && rtx_equal_p (XEXP (cond, 0), true_rtx) && rtx_equal_p (XEXP (cond, 1), false_rtx) Thanks, Haijian Zhang -----Original Message----- From: Segher Boessenkool [mailto:seg...@kernel.crashing.org] Sent: Thursday, April 23, 2020 7:38 PM To: Richard Biener <richard.guent...@gmail.com> Cc: Zhanghaijian (A) <z.zhanghaij...@huawei.com>; gcc-patches@gcc.gnu.org Subject: Re: [PATCH PR94708] rtl combine should consider NaNs when generate fp min/max Hi! On Thu, Apr 23, 2020 at 11:05:22AM +0200, Richard Biener wrote: > On Thu, Apr 23, 2020 at 10:42 AM Zhanghaijian (A) > <z.zhanghaij...@huawei.com> wrote: > > This is a simple fix for pr94708. > > It's unsafe for rtl combine to generate fp min/max under > > -funsafe-math-optimizations, considering NaNs. > > We can only do this kind of transformation under > > -funsafe-math-optimizations and -ffinite-math-only. > > Bootstrap and tested on aarch64 Linux platform. No new regression witnessed. > > > > Any suggestion? > > Please do not check flags, instead use && !HONOR_NANS (mode) Yeah, good point. > What about signed zeros? -funsafe-math-optimizations implies -fno-signed-zeros. > The GENERIC folding routine producing > min/max is avoiding it when those are honored (and it doesn't check > flag_unsafe_math_optmizations at all). > > Certainly the patch is an incremental correct fix, with the flag > testing replaced by the mode feature testing. Yeah, and the SMAX etc. definition is so weak that it isn't obvious that this combine transform is valid without this flag. We can or should fix that, of course :-) Segher
pr94708-v2.patch
Description: pr94708-v2.patch