[PATCH PR94708] rtl combine should consider NaNs when generate fp min/max

Segher Boessenkool segher@kernel.crashing.org
Thu Apr 23 11:37:33 GMT 2020


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.zhanghaijian@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


More information about the Gcc-patches mailing list