[polly] r279734 - Introduce unittests.

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 25 12:44:29 PDT 2016


Hi Tobias,

depends whether the caller always treats the number as a signed value.
The only caller IslExprBuilder::createInt most likely calls sext on
it, therefore it is correct (assuming that also the entire
IslExprBuilder chain assumed signed values). Ie we can remove the
fixme.

Could we maybe add documentation to this function that points it out?

Michael



2016-08-25 20:26 GMT+02:00 Tobias Grosser <tobias at grosser.es>:
> Hi Michael,
>
> I just looked into this FIXME below myself, and it seems the code might
> actually be correct, as we always generate the smallest APInt that is
> large enough to model a certain value. For -1, this APInt has a size of
> 1 bit. If interpreted as signed,
> it can contain the values 0 and -1, with 0 modeled as '0' and -1 modeled
> as '1' in two's complement representation. If interpreted as unsigned,
> these values map to '0' and '1'. Hence, the test below seems to be
> correct to me:
>
>> +  {
>> +    auto *IslNOne = isl_val_int_from_si(IslCtx, -1);
>> +    auto APNOne = APIntFromVal(IslNOne);
>> +    // APInt has no sign bit, so never equals to a negative number.
>> +    // FIXME: The canonical representation of a negative APInt is two's
>> +    // complement.
>> +    EXPECT_EQ(APNOne, 1);
>> +  }
>
> It seems we just missed that APInt is of size one bit. What are your
> thoughts?
>
> Best,
> Tobias


More information about the llvm-commits mailing list