On 3/10/23 09:53, Richard Biener wrote:
On Fri, 10 Mar 2023, Jakub Jelinek wrote:

Coming back to this...

  /* Temporarily disable -ffinite-math-only, so that frange::set doesn't
     reduce the range back to real_min_representable (type) as lower bound
     or real_max_representable (type) as upper bound.  */
  bool save_flag_finite_math_only = flag_finite_math_only;
  flag_finite_math_only = false;
  ret.set (type, lb, ub);
  if (lhs.kind () != VR_VARYING)
    {
      ret.clear_nan ();
      ret.union_ (lhs);
    }
  flag_finite_math_only = save_flag_finite_math_only;

It looks like what you want to do is be able to create a range with a known NAN state, but without the setter reducing the range to min/max_representable.

How about we enhance the API to provide:

1. Constructor with a known NAN state.
2. Setter with a flag to keep it from canonicalizing into min/max_representable.

The flag in 2 could in the future be saved in the frange object to keep union and friends from further canonicalization.

So the above could be written as:

        // Construct [lb, ub] with a known NAN state.
        frange tmp (lb, ub, lhs.get_nan_state ());

        // Set RET without dropping/reducing the range to MIN/MAX.
        ret.set (tmp, FRANGE_FLAG_NO_REPRESENTABLE_REDUCTION);

An alternative is to allow the setter to set everything:

        ret.set (type, lb, ub,
                lhs.get_nan_state (),
                FRANGE_FLAG_NO_REPRESENTABLE_REDUCTION);

Would this work? I'd be happy to whip up something this week, or if preferred, leave it to the next release.

Aldy

Reply via email to