<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 5 February 2015 at 13:04,  <span dir="ltr"><<a href="mailto:dag@cray.com" target="_blank">dag@cray.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><<a href="mailto:dag@cray.com">dag@cray.com</a>> writes:<br>
<br>
> I've been debugging some strange happenings over here and I put an<br>
> assert in APInt to catch what I think is the source of the problem:<br>
><br>
>   int64_t getSExtValue() const {<br>
>     // An i1 -1 is unrepresentable.<br>
>     assert(BitWidth != 1 && "Signed i1 value is not representable!");<br>
><br>
> To me an i1 -1 makes no sense whatsoever.  It is not representable in<br>
> twos-complement form.  It cannot be distinguished from unsigned i1 1.<br>
><br>
> It turns out this assert triggers all over the place.  Before I dive<br>
> into this rat hole I'd like to confirm with others my sense that we<br>
> shouldn't be creating i1 -1 values.  Is there some legitimate reason to<br>
> do so?<br>
<br>
</span>I should clarify this.  The problem isn't with i1 -1 per se, it's the<br>
fact that we need to also represent an unsigned i1 1 value.<br>
<br>
The problem appears to be that somewhere we request a sign-extended i1 1<br>
constant value when we really want the zero-extended i1 1 value.  That's<br>
probably actually the real error but I'm still wondering whether APInt<br>
should be used to represent both signed and unsigned i1 1.<br></blockquote><div><br></div><div>This is in no way specific to i1's. Given an i8, you can have anything from i8 -128 up to i8 255, inclusive. That's a larger <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important;background-color:rgb(255,255,255)">range </span>than 8 bits can represent.</div><div><br></div><div>Nick</div><div><br></div></div></div></div>