> This is why I got a bit uncertain and hoped to get some feedback whether > my intuition is correct or not. Meanwhile I also found a comment in > the internals book at "14.7 Constant Expression Types" where we have: > > "Constants generated for modes with fewer bits than in HOST_WIDE_INT > must be sign extended to full width (e.g., with gen_int_mode). > [...] > Note however that values are neither inherently signed nor > inherently unsigned; where necessary, signedness is determined by > the rtl operation instead." > > At least this and the assert statement document that the normal form of > a CONST_INT is kind of special w.r.t. unsigned integers. Is there > anyone who can shed some light on _why_ such a normal form was chosen?
In RTL integral values have no sign, they just represent a given pattern of bits so, in order to have a 1-to-1 mapping, you need to choose a canonical form. The signed form is probably more natural and, since CONST_INTs have no mode, the same objects are used for e.g. QImode and HImode, which means that you need to sign-extend the bit pattern. -- Eric Botcazou