This is the mail archive of the gcc-bugs@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]

Re: gcc const int expressions and negative constants



Neil Booth <NeilB@earthling.net> writes:

> What I'm confused about is whether the correct form of constants
> appearing in QImode expressions is (HOST_WIDE_INT) 255 or -1?  The

It's -1.

> initial line
> 
>   unsigned char integer[2] = {255};
> 
> produces a QImode store with constant -1.  Combine makes that into a
> HImode store with constant 255.  Then

This is right.

>   sign = integer[0];
> 
> produces another QImode store of -1, 

This is also right.

> but then the mode is lost in the final comparison to 255.

Probably something is not truncating QImode -1 into SImode 255 when
converting between int and unsigned char in the expression

sign == 255

> This seems like a large can of worms.  If someone can tell me what the
> intended correct method of using the constants is, I can try and fix
> it.

There are lots of bugs like these; we are tracking them down one by one.

-- 
- Geoffrey Keating <geoffk@cygnus.com>

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