This is the mail archive of the gcc@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: When to ingore signed vs. unsigned comparison?


On Tue, 8 Feb 2005, Richard Guenther wrote:

> In tackling the missed folding of &a[2]-1 to &a[1], I'm
> getting unsigned indices instead of signed ones.  For
> further allowing &a[1] == &a[1] to be folded, I need a way
> to say if I can ignore that 1 (lhs) is unsinged and 1 (rhs)
> is signed.
>
> I.e. we don't fold &a[1] == &a[1U] at the moment - how to fix
> this?  I tried using may_negate_without_overflow_p, but that
> does another thing.  Is there some utility function that would
> help me doing this?  Any hints?

The question simplified boils down to: given two trees a and b
with one of them being an (signed or unsigned) integer constant,
when and how do I convert the integer constant to the type of
the other tree?  The simplest case would be f.i. int i and 5U
- how do I check that it is legal to convert 5U to int, and how
do I do this?

Using fold_convert_const_int_from_int and checking TREE_CONSTANT_OVERFLOW
on the result doesn't work - I get 0fffffffb from -5 to unsinged
and no overflow set.

Richard.

--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/


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