On Wed, Nov 09, 2022 at 02:32:55PM +0100, Jakub Jelinek wrote: > On Wed, Nov 09, 2022 at 02:14:19PM +0100, Aldy Hernandez wrote: > > On Wed, Nov 9, 2022 at 1:48 PM Jakub Jelinek <ja...@redhat.com> wrote: > > > > > > On Wed, Nov 09, 2022 at 08:07:57AM +0100, Aldy Hernandez wrote: > > > > The PLUS_EXPR was always meant to be a template for further > > > > development, since most of the binary operators will share a similar > > > > structure. This patch abstracts out the common bits into the default > > > > definition for range_operator_float::fold_range() and provides an > > > > rv_fold() to be implemented by the individual entries wishing to use > > > > the generic folder. This is akin to what we do with fold_range() and > > > > wi_fold() in the integer version of range-ops. > > > > > > Shouldn't foperator_mult be very similar to this (except that until > > > division is done op[12]_range can't be implemented), with the exception > > > that the invalid case isn't -INF + INF or INF + -INF, but > > > 0 * +/-INF or +/-INF * 0? > > > > Multiplication and division are tricky because you have to keep track > > of signs to order the resulting range. It's the most annoying pattern > > we have for integers: > > Ah, you're right. > Reminds me of check_for_binary_op_overflow for multiplication.
On the other side, thinking more about it, it should be easier than integral, because we don't need to deal with unsigned/wrap around and overflows aren't undefined, but infinities (though I guess we still have even for +/- the question how actually say PDP floats or ARM non-IEEE mode __fp16 behave on overflows for floats that don't support infinities, if it is saturating on HUGE_VAL*/-HUGE_VAL* or wraps around). So just do the cross products, sort them to create the final range, clear_nans on it and provide nans the normal way? Jakub