Aldy Hernandez <al...@redhat.com> writes:
> On 10/11/19 10:42 AM, Richard Sandiford wrote:
>> The range-tracking code has a pretty hard-coded assumption that
>> is_gimple_min_invariant is equivalent to "INTEGER_CST or invariant
>> ADDR_EXPR".  It seems better to add a predicate specifically for
>> that rather than contiually fight cases in which it can't handle
>> other invariants.
>
> I was going to suggest we normalize ranges to numerics completely before 
> folding.  That is, replacing normalize_addresses() here:
>
>    *vr = op->fold_range (expr_type,
>                       vr0.normalize_addresses (),
>                       vr1.normalize_addresses ());
>
> ...into normalize_symbolics().  But I suppose getting the gate correct 
> is even better.  Thanks for taking the care of this extensive and manual 
> change.
>
> The patch looks good to me.  However, I do wonder if VRP and 
> subsidiaries can't handle non-integer invariants, if we shouldn't 
> disallow them from the setters as well:
>
> void
> value_range_base::set (tree val)
> {
>    gcc_assert (TREE_CODE (val) == SSA_NAME || is_gimple_min_invariant 
> (val));
>    if (TREE_OVERFLOW_P (val))
>      val = drop_tree_overflow (val);
>    set (VR_RANGE, val, val);
> }
>
> void
> value_range::set (tree val)
> {
>    gcc_assert (TREE_CODE (val) == SSA_NAME || is_gimple_min_invariant 
> (val));
>    if (TREE_OVERFLOW_P (val))
>      val = drop_tree_overflow (val);
>    set (VR_RANGE, val, val, NULL);
> }
>
> This would still allow setting of VARYING and UNDEFINED, but disallow 
> poly-ints, etc from a range.
>
> Was this a small oversight, or was there a reason you left those in?

Yeah, this was intentional.  The patch is effectively treating
POLY_INY_CST as symbolic rather than constant.  (It's really somewhere
in the middle: it's at least a function invariant, but the invariant
depends on a runtime target property.)  So places like here that
can handle both symbolics and constants should be able to handle
POLY_INT_CST wihout problems.  We just need to make sure that
POLY_INT_CSTs aren't treated as constants for range tracking,
because they're not "constant enough" there.

Thanks,
Richard

Reply via email to