On Thu, May 03, 2018 at 11:44:09AM +0200, Richard Biener wrote: > > + *RESULT = nextafter (*ARG0, *ARG1) > > + > > + or > > + > > + *RESULT = nexttoward (*ARG0, *ARG1) > > + > > + in format FORMAT. Return true on success. */ > > + > > +static bool > > +fold_const_nextafter (real_value *result, const real_value *arg0, > > + const real_value *arg1, const real_format *format) > > +{ > > + if (flag_signaling_nans > > HONOR_SNANS ()?
That requires a machine_mode or tree, but I don't have either of those, nor the caller (fold_const_call_sss) has those. I could change it to: if (flag_signalling_nans && !flag_finite_math_only && format->has_nans so that it would better duplicate what HONOR_SNANS actually tests. Though, I think it is ok to punt if one of the operands is a signalling nan even if flag_signalling_nans. > > + && (REAL_VALUE_ISSIGNALING_NAN (*arg0) > > + || REAL_VALUE_ISSIGNALING_NAN (*arg1))) > > + return false; > > + > > + /* Don't handle composite modes, nor decimal, nor modes without > > + inf or denorm at least for now. */ > > + if (format->pnan < format->p > > + || format->b == 10 > > + || !format->has_inf > > + || !format->has_denorm) > > + return false; > > I wonder if we should assert in real_nextafter that we can actually > handle the input? It likely returns garbage if fed with decimal float > stuff? Yes, but nobody would call it even if we removed the || format->b == 10 condition, the only builtins we fold this for have non-decimal float/double/long double arguments. I can surely add an assert with the same set of checks as the above ones. Jakub