https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126220

            Bug ID: 126220
           Summary: vect_get_range_info should be removed and just use
                    range_of_expr
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Keywords: compile-time-hog, internal-improvement
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Currently it does:
```
/* Return true if we have a useful VR_RANGE range for VAR, storing it
   in *MIN_VALUE and *MAX_VALUE if so.  Note the range in the dump files.  */

bool
vect_get_range_info (tree var, wide_int *min_value, wide_int *max_value)
{
  int_range_max vr;
  tree vr_min, vr_max;
  get_range_query (cfun)->range_of_expr (vr, var);
  if (vr.undefined_p ())
    vr.set_varying (TREE_TYPE (var));
  value_range_kind vr_type = get_legacy_range (vr, vr_min, vr_max);
  *min_value = wi::to_wide (vr_min);
  *max_value = wi::to_wide (vr_max);
  wide_int nonzero = get_nonzero_bits (var);
  signop sgn = TYPE_SIGN (TREE_TYPE (var));
  if (intersect_range_with_nonzero_bits (vr_type, min_value, max_value,
                                         nonzero, sgn) == VR_RANGE)
    {
      if (dump_enabled_p ())
        {
          dump_generic_expr_loc (MSG_NOTE, vect_location, TDF_SLIM, var);
          dump_printf (MSG_NOTE, " has range [");
          dump_hex (MSG_NOTE, *min_value);
          dump_printf (MSG_NOTE, ", ");
          dump_hex (MSG_NOTE, *max_value);
          dump_printf (MSG_NOTE, "]\n");
        }
      return true;
    }
  else
    {
      if (dump_enabled_p ())
        {
          dump_generic_expr_loc (MSG_NOTE, vect_location, TDF_SLIM, var);
          dump_printf (MSG_NOTE, " has no range info\n");
        }
      return false;
    }
}
```

Since the non-zero bits are done correctly for the range, then this could just
become using lower_bound and upper_bound on the vr range.

vect_determine_precisions_from_range for an example definitely needs an
improvement which I filed PR 117244 for ...

Reply via email to