Skip to content

Commit

Permalink
Misc range temporary fixes.
Browse files Browse the repository at this point in the history
This fixes a couples places that were using int_range_max, but needed
a generic temporary.  Found while merging the frange work.

Also, copying between range temporaries is actually useful :).

Tested on x86-64 Linux.

gcc/ChangeLog:

	* gimple-range-cache.cc (ranger_cache::range_from_dom): Use
	Value_Range.
	* gimple-range.cc (gimple_ranger::register_inferred_ranges): Same.
	* value-range.h (Value_Range::Value_Range): Implement copy
	constructor for Value_Range.
  • Loading branch information
aldyh committed Jun 3, 2022
1 parent f4fa81b commit 0fd3c70
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gcc/gimple-range-cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ ranger_cache::range_from_dom (vrange &r, tree name, basic_block start_bb,
// each incoming edge now and accumulate the results.
r.set_undefined ();
edge_iterator ei;
int_range_max er;
Value_Range er (TREE_TYPE (name));
FOR_EACH_EDGE (e, ei, prev_bb->preds)
{
edge_range (er, e, name, RFD_READ_ONLY);
Expand Down
9 changes: 6 additions & 3 deletions gcc/gimple-range.cc
Original file line number Diff line number Diff line change
Expand Up @@ -461,17 +461,20 @@ gimple_ranger::register_inferred_ranges (gimple *s)
tree lhs = gimple_get_lhs (s);
if (lhs)
{
int_range_max tmp;
Value_Range tmp (TREE_TYPE (lhs));
if (range_of_stmt (tmp, s, lhs) && !tmp.varying_p ()
&& update_global_range (tmp, lhs) && dump_file)
{
value_range vr = tmp;
// ?? This section should be adjusted when non-iranges can
// be exported. For now, the only way update_global_range
// above can succeed is with an irange so this is safe.
value_range vr = as_a <irange> (tmp);
fprintf (dump_file, "Global Exported: ");
print_generic_expr (dump_file, lhs, TDF_SLIM);
fprintf (dump_file, " = ");
vr.dump (dump_file);
int_range_max same = vr;
if (same != tmp)
if (same != as_a <irange> (tmp))
{
fprintf (dump_file, " ... irange was : ");
tmp.dump (dump_file);
Expand Down
8 changes: 7 additions & 1 deletion gcc/value-range.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ class Value_Range
Value_Range ();
Value_Range (const vrange &r);
Value_Range (tree type);
Value_Range (const Value_Range &);
void set_type (tree type);
vrange& operator= (const vrange &);
bool operator== (const Value_Range &r) const;
Expand Down Expand Up @@ -344,7 +345,6 @@ class Value_Range
unsupported_range m_unsupported;
vrange *m_vrange;
int_range_max m_irange;
DISABLE_COPY_AND_ASSIGN (Value_Range);
};

inline
Expand All @@ -370,6 +370,12 @@ Value_Range::Value_Range (tree type)
init (type);
}

inline
Value_Range::Value_Range (const Value_Range &r)
{
m_vrange = r.m_vrange;
}

// Initialize object so it is possible to store temporaries of TYPE
// into it.

Expand Down

0 comments on commit 0fd3c70

Please sign in to comment.