This is the mail archive of the
mailing list for the GCC project.
Re: When to ingore signed vs. unsigned comparison?
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 8 Feb 2005 13:33:02 +0100 (CET)
- Subject: Re: When to ingore signed vs. unsigned comparison?
On Tue, 8 Feb 2005, Richard Guenther wrote:
> In tackling the missed folding of &a-1 to &a, I'm
> getting unsigned indices instead of signed ones. For
> further allowing &a == &a 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 == &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 Guenther <richard dot guenther at uni-tuebingen dot de>