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.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
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 |
Comment Actions
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.