Improve documentation and testing for isl_valFromAPInt
authorTobias Grosser <tobias@grosser.es>
Fri, 26 Aug 2016 12:01:07 +0000 (12:01 +0000)
committerTobias Grosser <tobias@grosser.es>
Fri, 26 Aug 2016 12:01:07 +0000 (12:01 +0000)
commit437200089d5712d3714880ee2eb64d855dfc60a6
tree4e1827d3ff82df558ffd2660e438e78d654e61d6
parent0a1986790c29118b756df41212bd45a2d2712770
Improve documentation and testing for isl_valFromAPInt

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. This change did
not uncover a bug in the old implementation, but was introduced to increase
readability.

We update the tests to add a test case for this special case and use this
opportunity to also test a number larger than 64 bit. Finally, we order the
arguments of the test cases to make sure the expected output is first. This
helps readability in case of failing test cases as gtest assumes the first value
to be the exected value.

Reviewed-by: Michael Kruse <llvm@meinersbur.de>
Differential Revision: https://reviews.llvm.org/D23917

llvm-svn: 279815
polly/include/polly/Support/GICHelper.h
polly/lib/Support/GICHelper.cpp
polly/unittests/Isl/IslTest.cpp