This is an archive of the discontinued LLVM Phabricator instance.

Improve documentation and testing for isl_valFromAPInt
ClosedPublic

Authored by grosser on Aug 26 2016, 4:29 AM.

Details

Summary

The recent unit tests we gained made clear that the semantics of
isl_valFromAPInt are not clear, due to missing documentation. In this change we
document both the calling interface as well as the implementation of
isl_valFromAPInt. We also make the implementation easier to read by removing
integer wrappig in abs() when passing in the minimal integer value for a given
bitwidth. Even though wrapping and subsequently interpreting the result as
unsigned value gives the correct result, this is far from obvious. Instead, we
explicitly add one more bit to the input type to ensure that abs will never
wrap. Finally, we add a test case for this special case and also test a number
larger than 64 bit.

Diff Detail

Repository
rL LLVM

Event Timeline

grosser updated this revision to Diff 69341.Aug 26 2016, 4:29 AM
grosser retitled this revision from to Improve documentation and testing for isl_valFromAPInt.
grosser updated this object.
grosser added a reviewer: Meinersbur.
grosser added subscribers: llvm-commits, pollydev.
Meinersbur accepted this revision.Aug 26 2016, 4:52 AM
Meinersbur edited edge metadata.

LGTM

lib/Support/GICHelper.cpp
45 ↗(On Diff #69341)

Is this a bug discovered by the additional tests?

unittests/Isl/IslTest.cpp
117 ↗(On Diff #69341)

I reversed the arguments of EXPECT_EQ in APIntToIslVal because how a fail is printed:

C:\Users\Meinersbur\src\llvm\tools\polly\unittests\Isl\IslTest.cpp(71): error: Value of: 1
Expected: APNOne
Which is: 16-byte object <02-00 00-00 F6-7F 00-00 02-00 00-00 00-00 00-00>

should we reverse all of them (for consistency),such that the output would be:

C:\Users\Meinersbur\src\llvm\tools\polly\unittests\Isl\IslTest.cpp(71): error: Value of: APNOne
  Actual: 16-byte object <02-00 00-00 F6-7F 00-00 02-00 00-00 00-00 00-00>
Expected: 1
This revision is now accepted and ready to land.Aug 26 2016, 4:52 AM
This revision was automatically updated to reflect the committed changes.

Thank you for your comments. I explained in the commit message that the implementation change did not uncover any correctness issues (as I am aware of) and also reordered the arguments of EXPT_EQ in APIntToIslVal. In a subsequent commit I will do the same for APIntFromVal.

Thank you for your comments. I explained in the commit message that the implementation change did not uncover any correctness issues (as I am aware of) and also reordered the arguments of EXPT_EQ in APIntToIslVal.

I missed the summary message, sorry. I should give it more attention in reviews.