This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH COMMITTED: Fix Ada build

On 01 May 2007 10:57:25 -0700, Ian Lance Taylor <> wrote:
My apologies for breaking the Ada build.  I didn't think my patch
could cause it to break, but clearly I was wrong.  As far as I can
tell the code was loosely hanging together before.  The Ada frontend
sets TYPE_MAX_VALUE of a subtype to have the type of the main type.
This causes VRP to become ineffective in its tests of infinity, but I
guess that never mattered.  The effect of my patch to tree.c to cause
TYPE_MAX_VALUE of a type variant to have the type of that variant was
to cause some type mismatches in VRP when using Ada subtypes.  These
type mismatches managed to lead to confusion with Ada subtypes, in
which the cache of integers associated with each type themselves had
the wrong type.  There may still be something dubious going on in this
area; I'm not sure.

In any case this patch fixes the VRP problem in PR 31710 in what some
people think is a better way anyhow, by comparing INT_CSTs by value
rather than ==.

Bootstrapped and tested on i686-pc-linux-gnu, including Ada.
Committed to mainline.  I will commit to 4.2 branch when it is open
for changes.


2007-05-01 Ian Lance Taylor <>

        PR tree-optimization/31739
        * tree-vrp.c (vrp_val_is_max): New static function.
        (vrp_val_is_min): New static function.
        (set_value_range_to_value): Use TYPE_{MAX,MIN}_VALUE rather than
        copying the node.
        (set_value_range): Use vrp_val_is_{max,min}.
        (extract_range_from_assert): Likewise.
        (extract_range_from_binary_expr): Likewise.
        (extract_range_from_unary_expr): Likewise.
        (dump_value_range, vrp_meet): Likewise.
        (vrp_visit_phi_node): Likewise.
        * tree.c (build_distinct_type_copy): Revert change of 2007-04-27.

Index: tree-vrp.c =================================================================== --- tree-vrp.c (revision 124227) +++ tree-vrp.c (working copy) @@ -202,6 +202,36 @@ is_overflow_infinity (tree val) }

+/* Return whether VAL is equal to the maximum value of its type. This + will be true for a positive overflow infinity. We can't do a + simple equality comparison with TYPE_MAX_VALUE because C typedefs + and Ada subtypes can produce types whose TYPE_MAX_VALUE is not == + to the integer constant with the same value in the type. */ + +static inline bool +vrp_val_is_max (tree val) +{ + tree type_max = TYPE_MAX_VALUE (TREE_TYPE (val)); + + return (val == type_max + || (type_max != NULL_TREE + && operand_equal_p (val, type_max, 0))); +}

Why use operand_equal_p and the short circuits when tree_int_cst_equal does the same thing?

tree_int_cst_equal (tree t1, tree t2)
 if (t1 == t2)
   return 1;

 if (t1 == 0 || t2 == 0)
   return 0;

     && TREE_CODE (t2) == INTEGER_CST
     && TREE_INT_CST_LOW (t1) == TREE_INT_CST_LOW (t2)
     && TREE_INT_CST_HIGH (t1) == TREE_INT_CST_HIGH (t2))
   return 1;

 return 0;

I don't think operand_equal_p should be used for value based compares
-- it was done to structurally compare trees.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]