[LLVMdev] i1 Values
Rob Cameron
cameron at cs.sfu.ca
Thu Feb 5 13:14:07 PST 2015
If the type is interpreted as signed, then -1 is a proper value.
For signed integer type of n bits, the values that are
representable are in the range -2^(n-1)...2^(n-1)-1), e.g.,
-128...127 for i8. For i1, the values are in the range -1...0.
So -1 and 0 are the two values that can be represented.
----- Original Message -----
> I've been debugging some strange happenings over here and I put an
> assert in APInt to catch what I think is the source of the problem:
>
> int64_t getSExtValue() const {
> // An i1 -1 is unrepresentable.
> assert(BitWidth != 1 && "Signed i1 value is not representable!");
>
> To me an i1 -1 makes no sense whatsoever. It is not representable in
> twos-complement form. It cannot be distinguished from unsigned i1 1.
>
> It turns out this assert triggers all over the place. Before I dive
> into this rat hole I'd like to confirm with others my sense that we
> shouldn't be creating i1 -1 values. Is there some legitimate reason to
> do so?
>
> -David
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list