Re: Fold and integer types with sub-ranges

2007-02-25 Thread Richard Kenner
> Note that having TREE_TYPE(type)!=NULL does not imply that the type and the > base type are inequivalent. For example, if you declare a type Int as > follows: > subtype Int is Integer; > then TREE_TYPE(type_for_Int)=type_for_Integer, but the types are equivalent, > in particular they have

Re: Fold and integer types with sub-ranges

2007-02-25 Thread Duncan Sands
On Saturday 24 February 2007 14:27:36 Richard Kenner wrote: > > Sure - I wonder if there is a reliable way of testing whether we face > > a non-base type in the middle-end. I suppose TREE_TYPE (type) != NULL > > won't work in all cases... (?) > > That's the right way as far as I know. Note that

Re: Fold and integer types with sub-ranges

2007-02-24 Thread Richard Kenner
> Sure - I wonder if there is a reliable way of testing whether we face > a non-base type in the middle-end. I suppose TREE_TYPE (type) != NULL > won't work in all cases... (?) That's the right way as far as I know. > I agree. But appearantly fold does not care about base vs. non-base > types a

Re: Fold and integer types with sub-ranges

2007-02-24 Thread Richard Guenther
On Fri, 23 Feb 2007, Richard Kenner wrote: > > That said, this whole thing is a can of worms. Suppose the compiler wants > > to > > calculate t+1. Of course you do something like this: > > > > int_const_binop (PLUS_EXPR, t, build_int_cst (TREE_TYPE (t), 1), 0); > > > > But if 1 is not in the

Re: Fold and integer types with sub-ranges

2007-02-23 Thread Richard Kenner
> That said, this whole thing is a can of worms. Suppose the compiler wants to > calculate t+1. Of course you do something like this: > > int_const_binop (PLUS_EXPR, t, build_int_cst (TREE_TYPE (t), 1), 0); > > But if 1 is not in the type of t, you just created an invalid value! Yes, but why n

Re: Fold and integer types with sub-ranges

2007-02-23 Thread Richard Guenther
On Fri, 23 Feb 2007, Duncan Sands wrote: > > Currently for example in fold_sign_changed_comparison we produce > > integer constants that are not inside the range of its type values > > denoted by [TYPE_MIN_VALUE (t), TYPE_MAX_VALUE (t)]. For example > > consider a type with range [10, 20] and the

Re: Fold and integer types with sub-ranges

2007-02-23 Thread Duncan Sands
> Currently for example in fold_sign_changed_comparison we produce > integer constants that are not inside the range of its type values > denoted by [TYPE_MIN_VALUE (t), TYPE_MAX_VALUE (t)]. For example > consider a type with range [10, 20] and the comparison created by > the Ada frontend: > > i

Fold and integer types with sub-ranges

2007-02-23 Thread Richard Guenther
Currently for example in fold_sign_changed_comparison we produce integer constants that are not inside the range of its type values denoted by [TYPE_MIN_VALUE (t), TYPE_MAX_VALUE (t)]. For example consider a type with range [10, 20] and the comparison created by the Ada frontend: if ((signed ch