This is the mail archive of the gcc-patches@gcc.gnu.org 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] Fix optimization regression in constant folder


On 9/17/07, Eric Botcazou <ebotcazou@adacore.com> wrote:
> > I don't think this is correct.  [Note: all this TYPE_IS_SIZETYPE
> > specialities have to go somewhen - they really confuse things]
>
> Well, this is the documented behaviour of TYPE_IS_SIZETYPE:
>
> /* In an INTEGER_TYPE, it means the type represents a size.  We use
>    this both for validity checking and to permit optimizations that
>    are unsafe for other types.  Note that the C `size_t' type should
>    *not* have this flag set.  The `size_t' type is simply a typedef
>    for an ordinary integer type that happens to be the type of an
>    expression returned by `sizeof'; `size_t' has no special
>    properties.  Expressions whose type have TYPE_IS_SIZETYPE set are
>    always actual sizes.  */
>
> and we really need this to simplify complex size calculations in Ada.
>
> > First of all, this misses a (optimization) testcase.  Second, why do we use
> > signed sizetype calculations when we want unsigned semantics as far as
> > overflow behavior is concerned?
>
> I don't think we want unsigned semantics, we want "size" semantics, i.e we
> don't care about overflow in size calculations.

Well, we need to be consistent and the above documentation is not clear
what happens on overflow.  Either assume overflow of size types wrap or
overflow on them is undefined - if you stick to one or the other behavior
then I'd rather have you update all the TYPE_OVERFLOW_* predicates
than fixing this one single place.

Richard.


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