On August 20, 2017 10:46:54 AM GMT+02:00, Aldy Hernandez <[email protected]>
wrote:
>Hi folks.
>
>Calling wi::max_value() of a boolean_type creates a wide_int with all
>bits set, not just the least significant bit.
>
>tree type = boolean_type_node;
>wide_int x = wi::max_value (TYPE_PRECISION (type), TYPE_SIGN (type));
>(gdb) print x.dump()
>[0xffffffffffffffff], precision = 1
>
>However, one can also create a boolean of true with:
>
>wide_int one = wi::uhwi (1, TYPE_PRECISION (boolean_type_node));
>(gdb) print one.dump()
>[0x1], precision = 1
Looks like this one fails to be sign extended.
Richard.
>These will not be equal to each other because wi::eq_p() will only
>strip
>off excess bits when <is_sign_extended=false>. However,
>is_sign_extended=true for all wide_int's.
>
>Am I doing something wrong?
>
>Could I change wi::max_value() to strip off excess bits, instead of
>setting all bits like it's currently doing:
>
>wide_int
>wi::max_value (unsigned int precision, signop sgn)
>{
> gcc_checking_assert (precision != 0);
> if (sgn == UNSIGNED)
> /* The unsigned max is just all ones. */
> return shwi (-1, precision);
>...
>...
>
>Or perhaps change wi::eq_p() to strip off excess bits?
>
>Or am I missing something else entirely?
>Aldy