[polly] r297522 - [unittest] Do not convert large unsigned long to isl::val

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 10 14:25:39 PST 2017


Author: grosser
Date: Fri Mar 10 16:25:39 2017
New Revision: 297522

URL: http://llvm.org/viewvc/llvm-project?rev=297522&view=rev
Log:
[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.

Modified:
    polly/trunk/unittests/Isl/IslTest.cpp

Modified: polly/trunk/unittests/Isl/IslTest.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/unittests/Isl/IslTest.cpp?rev=297522&r1=297521&r2=297522&view=diff
==============================================================================
--- polly/trunk/unittests/Isl/IslTest.cpp (original)
+++ polly/trunk/unittests/Isl/IslTest.cpp Fri Mar 10 16:25:39 2017
@@ -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());




More information about the llvm-commits mailing list