@@ -2485,8 +2485,7 @@ propagate_bits_across_jump_function (cgraph_edge *cs, int idx,
jfunc->m_vr->get_vrange (vr);
if (!vr.undefined_p () && !vr.varying_p ())
{
- irange &r = as_a <irange> (vr);
- irange_bitmask bm = r.get_bitmask ();
+ irange_bitmask bm = vr.get_bitmask ();
widest_int mask
= widest_int::from (bm.mask (), TYPE_SIGN (parm_type));
widest_int value
@@ -6346,14 +6345,13 @@ ipcp_store_vr_results (void)
{
Value_Range tmp = plats->m_value_range.m_vr;
tree type = ipa_get_type (info, i);
- irange &r = as_a<irange> (tmp);
irange_bitmask bm (wide_int::from (bits->get_value (),
TYPE_PRECISION (type),
TYPE_SIGN (type)),
wide_int::from (bits->get_mask (),
TYPE_PRECISION (type),
TYPE_SIGN (type)));
- r.update_bitmask (bm);
+ tmp.update_bitmask (bm);
ipa_vr vr (tmp);
ts->m_vr->quick_push (vr);
}
@@ -6368,14 +6366,13 @@ ipcp_store_vr_results (void)
tree type = ipa_get_type (info, i);
Value_Range tmp;
tmp.set_varying (type);
- irange &r = as_a<irange> (tmp);
irange_bitmask bm (wide_int::from (bits->get_value (),
TYPE_PRECISION (type),
TYPE_SIGN (type)),
wide_int::from (bits->get_mask (),
TYPE_PRECISION (type),
TYPE_SIGN (type)));
- r.update_bitmask (bm);
+ tmp.update_bitmask (bm);
ipa_vr vr (tmp);
ts->m_vr->quick_push (vr);
}
@@ -2381,8 +2381,7 @@ ipa_compute_jump_functions_for_edge (struct ipa_func_body_info *fbi,
irange_bitmask bm (value, mask);
if (!addr_nonzero)
vr.set_varying (TREE_TYPE (arg));
- irange &r = as_a <irange> (vr);
- r.update_bitmask (bm);
+ vr.update_bitmask (bm);
ipa_set_jfunc_vr (jfunc, vr);
}
else if (addr_nonzero)
@@ -5785,8 +5784,8 @@ ipcp_get_parm_bits (tree parm, tree *value, widest_int *mask)
vr[i].get_vrange (tmp);
if (tmp.undefined_p () || tmp.varying_p ())
return false;
- irange &r = as_a <irange> (tmp);
- irange_bitmask bm = r.get_bitmask ();
+ irange_bitmask bm;
+ bm = tmp.get_bitmask ();
*mask = widest_int::from (bm.mask (), TYPE_SIGN (TREE_TYPE (parm)));
*value = wide_int_to_tree (TREE_TYPE (parm), bm.value ());
return true;
@@ -5857,8 +5856,7 @@ ipcp_update_vr (struct cgraph_node *node, ipcp_transformation *ts)
if (POINTER_TYPE_P (TREE_TYPE (parm))
&& opt_for_fn (node->decl, flag_ipa_bit_cp))
{
- irange &r = as_a<irange> (tmp);
- irange_bitmask bm = r.get_bitmask ();
+ irange_bitmask bm = tmp.get_bitmask ();
unsigned tem = bm.mask ().to_uhwi ();
unsigned HOST_WIDE_INT bitpos = bm.value ().to_uhwi ();
unsigned align = tem & -tem;
@@ -22,7 +22,7 @@ along with GCC; see the file COPYING3. If not see
#ifndef GCC_RANGE_OP_MIXED_H
#define GCC_RANGE_OP_MIXED_H
-void update_known_bitmask (irange &, tree_code, const irange &, const irange &);
+void update_known_bitmask (vrange &, tree_code, const vrange &, const vrange &);
bool minus_op1_op2_relation_effect (irange &lhs_range, tree type,
const irange &, const irange &,
relation_kind rel);
@@ -415,8 +415,8 @@ range_op_handler::operand_check_p (tree t1, tree t2, tree t3) const
// LH and RH.
void
-update_known_bitmask (irange &r, tree_code code,
- const irange &lh, const irange &rh)
+update_known_bitmask (vrange &r, tree_code code,
+ const vrange &lh, const vrange &rh)
{
if (r.undefined_p () || lh.undefined_p () || rh.undefined_p ()
|| r.singleton_p ())
@@ -68,6 +68,18 @@ unsupported_range::accept (const vrange_visitor &v) const
v.visit (*this);
}
+void
+vrange::update_bitmask (const class irange_bitmask &)
+{
+}
+
+irange_bitmask
+vrange::get_bitmask () const
+{
+ // Return all unknown bits for the given precision.
+ return irange_bitmask (TYPE_PRECISION (type ()));
+}
+
bool
unsupported_range::contains_p (tree) const
{
@@ -2010,7 +2022,7 @@ irange::get_bitmask () const
// normalize the range if anything changed.
void
-irange::set_nonzero_bits (const wide_int &bits)
+vrange::set_nonzero_bits (const wide_int &bits)
{
gcc_checking_assert (!undefined_p ());
irange_bitmask bm (wi::zero (TYPE_PRECISION (type ())), bits);
@@ -2020,7 +2032,7 @@ irange::set_nonzero_bits (const wide_int &bits)
// Return the nonzero bits in R.
wide_int
-irange::get_nonzero_bits () const
+vrange::get_nonzero_bits () const
{
gcc_checking_assert (!undefined_p ());
irange_bitmask bm = get_bitmask ();
@@ -98,6 +98,10 @@ public:
virtual ~vrange () { }
virtual tree lbound () const = 0;
virtual tree ubound () const = 0;
+ virtual void update_bitmask (const class irange_bitmask &);
+ virtual irange_bitmask get_bitmask () const;
+ wide_int get_nonzero_bits () const;
+ void set_nonzero_bits (const wide_int &bits);
bool varying_p () const;
bool undefined_p () const;
@@ -326,11 +330,8 @@ public:
virtual bool fits_p (const vrange &r) const override;
virtual void accept (const vrange_visitor &v) const override;
- void update_bitmask (const irange_bitmask &);
- irange_bitmask get_bitmask () const;
- // Nonzero masks.
- wide_int get_nonzero_bits () const;
- void set_nonzero_bits (const wide_int &bits);
+ virtual void update_bitmask (const class irange_bitmask &) override;
+ virtual irange_bitmask get_bitmask () const override;
protected:
void maybe_resize (int needed);
@@ -735,6 +736,9 @@ public:
bool zero_p () const { return m_vrange->zero_p (); }
tree lbound () const { return m_vrange->lbound (); }
tree ubound () const { return m_vrange->ubound (); }
+ irange_bitmask get_bitmask () const { return m_vrange->get_bitmask (); }
+ void update_bitmask (const class irange_bitmask &bm)
+ { return m_vrange->update_bitmask (bm); }
void accept (const vrange_visitor &v) const { m_vrange->accept (v); }
private:
void init (tree type);