This is an archive of the discontinued LLVM Phabricator instance.

Improve documentation and testing of APIntFromVal
ClosedPublic

Authored by grosser on Aug 26 2016, 12:19 AM.

Details

Summary

The recent unit tests we gained made clear that the semantics of APIntFromVal
are not clear, due to missing documentation. In this change we document both
the calling interface as well as the implementation of APIntFromVal. We also
make the implementation easier to read by removing the use of magic numbers.
Finally, we add tests to check the bitwidth of the created values as well as
the correct modeling of very large numbers.

Diff Detail

Event Timeline

grosser updated this revision to Diff 69323.Aug 26 2016, 12:19 AM
grosser retitled this revision from to Improve documentation and testing of APIntFromVal.
grosser updated this object.
grosser added a reviewer: Meinersbur.
grosser added subscribers: llvm-commits, pollydev.
Meinersbur edited edge metadata.Aug 26 2016, 3:06 AM

Thank you for the extensive documentation and adding more test cases.

include/polly/Support/GICHelper.h
46

assert() is not a guaranteed behavior. Better mention that the function can only be called on integer isl_vals.

55–64

Cool! More than I hoped for.

I'd remove the Unsigned column. It gives the impression that an unsigned interpretation would make sense. But maybe add a bitwidth column?

lib/Support/GICHelper.cpp
65

Can you mention 'negate'=='two's complement'?

unittests/Isl/IslTest.cpp
68

Suggestion:
"Compare with the two's complement of -1 in a 1-bit integer"

69–70

Remove fixme

150

Wow! Truly large integers.

grosser updated this revision to Diff 69337.Aug 26 2016, 3:20 AM
grosser edited edge metadata.

Address Michael's comments.

grosser marked 4 inline comments as done.Aug 26 2016, 3:21 AM

Thanks for the helpful remarks. I tried to address all of them.

Meinersbur accepted this revision.Aug 26 2016, 3:44 AM
Meinersbur edited edge metadata.

LGTM

unittests/Isl/IslTest.cpp
68–69

I had replacing the comment " APInt has no sign bit, so never equals to a negative number", but of course it is still a valid statement.

70

Nitpick: Dot at the end of the sentence.

This revision is now accepted and ready to land.Aug 26 2016, 3:44 AM
This revision was automatically updated to reflect the committed changes.
grosser marked 2 inline comments as done.Aug 26 2016, 3:52 AM

Thank you. I addressed the last two comments and committed.