From 9cc7e3561d834c7addda74760d82b9b6fb0ea93e Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Fri, 10 Mar 2017 22:25:39 +0000 Subject: [PATCH] [unittest] Do not convert large unsigned long to isl::val Currently the isl::val constructor only takes a signed long as parameter, which on Windows is only 32 bit large and can consequently not be used to obtain the same result when loading from the expression '(1ull << 32) - 1)' that we get when loading this value via isl_val_int_from_ui or when loading the value on Linux systems with 64 bit long data types. We avoid this issue by performing the shift and subtractiong within the isl::val. It would be nice to teach the isl++ bindings to construct isl::val from other integer types, but the current interface is not sufficient to do so. If constructors from both signed long and unsigned long are exposed, then integer literals that are of type 'int' and which must be converted to 'long' to match the constructor have two ambigious constructors to choose from, which result in a compiler error. The right solution is likely to additionally expose constructors from signed and unsigned int, but these are not yet available in the isl C interface and adding those adhoc to our bindings is something I would like to avoid for now. We should address this issue with a proper discussion on the isl side. llvm-svn: 297522 --- polly/unittests/Isl/IslTest.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/polly/unittests/Isl/IslTest.cpp b/polly/unittests/Isl/IslTest.cpp index 8bdd94824ab1..c8bc0fcb3ecd 100644 --- a/polly/unittests/Isl/IslTest.cpp +++ b/polly/unittests/Isl/IslTest.cpp @@ -140,7 +140,7 @@ TEST(Isl, APIntToIslVal) { { APInt APNOne(32, (1ull << 32) - 1, false); auto IslNOne = valFromAPInt(IslCtx, APNOne, false); - auto IslRef = isl::val(IslCtx, (1ull << 32) - 1); + auto IslRef = isl::val(IslCtx, 32).two_exp().sub_ui(1); EXPECT_EQ(IslNOne, IslRef); } @@ -227,7 +227,7 @@ TEST(Isl, IslValToAPInt) { } { - auto IslNOne = isl::val(IslCtx, (1ull << 32) - 1); + auto IslNOne = isl::val(IslCtx, 32).two_exp().sub_ui(1); auto APNOne = APIntFromVal(IslNOne); EXPECT_EQ((1ull << 32) - 1, APNOne); EXPECT_EQ(33u, APNOne.getBitWidth());