This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH RFC: Ensure TREE_TYPE (TYPE_MIN_VALUE (t)) == t
Mark Mitchell <mark@codesourcery.com> writes:
> Richard Guenther wrote:
> > On 4/28/07, Richard Kenner <kenner@vlsi1.ultra.nyu.edu> wrote:
> >> > Well, VRP never actually does the type comparison that I wrote. The
> >> > real question is whether, given a NEGATE_EXPR applied to 'max', this
> >> > test is flawed:
> >> >
> >> > if (max != TYPE_MIN_VALUE (TREE_TYPE (max)))
> >>
> >> I wouldn't want to make that assumption. Instead, I'd use something
> >> like operand_equal_p so that slight differences in types will be ignored.
> >> It's much more robust not to make such assumptions unless you absolutely
> >> have to. And there seem to be at least two cases where it's wrong:
> >> variants and subtypes.
> >
> > Yes, for this test I think !tree_int_cst_equal () is the correct thing
> > to check.
>
> Me too. I think we should basically never make direct comparisons
> (based on pointers) between types or constants; instead, use explicit
> comparison functions. Then, we can make the functions do quick pointer
> comparisons if that's safe.
I'm testing a patch to make this change. The patch also fixes the Ada
failure, which arises because Ada constructs types which fail the test
I mentioned earlier: TREE_TYPE (TYPE_MIN_VALUE (t)) == t. See the
assignments to TYPE_{MAX,MIN}_VALUE in gnat_to_gnu_entity in
ada/decl.c.
Ian