On Thu, Apr 27, 2023 at 01:46:19PM +0200, Aldy Hernandez wrote: > On 4/27/23 13:13, Jakub Jelinek wrote: > > > + unsigned bulps = targetm.libm_function_max_error (m_cfn, TYPE_MODE > > (type), > > + true); > > + if (bulps == ~0U) > > + r.set_varying (type); > > + else if (bulps == 0) > > + r.set (type, dconstm1, dconst1); > > + else > > + { > > + REAL_VALUE_TYPE boundmin, boundmax; > > + boundmax = dconst1; > > + while (bulps--) > > + frange_nextafter (TYPE_MODE (type), boundmax, dconstinf); > > + real_arithmetic (&boundmin, NEGATE_EXPR, &boundmax, NULL); > > + r.set (type, boundmin, boundmax); > > + } > > This seems like something we'll do over and over for other operations, > right? If so, could you abstract it into a separate function?
Not easily. E.g. take the difference between sin/cos, where the above grows the interval on both sides by bulps, vs. what I'm working on right now (sqrt), where it grows in one direction only (from dconstm0 toward dconstninf). There could be other functions which only grow the positive bound. Jakub