[PATCH] D67442: [Polly] Fix lib/Transform/ScheduleOptimizer.cpp compilation on Solaris

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 11 06:11:44 PDT 2019


ro created this revision.
ro added a reviewer: grosser.
ro added a project: Polly.
Herald added subscribers: llvm-commits, fedor.sergeev, jyknight.
Herald added a reviewer: bollu.
Herald added a project: LLVM.

`lib/Transform/ScheduleOptimizer.cpp` fails to compile on Solaris, both on the 9.x
branch (first noticed when running `test-release.sh` without `-no-polly`) and on trunk:

  /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp: In function ‘MicroKernelParamsTy getMicroKernelParams(const llvm::TargetTransformInfo*, polly::MatMulInfoTy)’:
  /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp:914:62: error: call of overloaded ‘sqrt(long unsigned int)’ is ambiguous
    914 |       ceil(sqrt(Nvec * LatencyVectorFma * ThroughputVectorFma) / Nvec) * Nvec;
        |                                                              ^
  In file included from /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/math.h:24,
                   from /usr/gcc/9/include/c++/9.1.0/cmath:45,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm-c/DataTypes.h:28,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/Support/DataTypes.h:16,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/ADT/Hashing.h:47,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/ADT/ArrayRef.h:12,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/include/polly/ScheduleOptimizer.h:12,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp:48:
  /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:220:21: note: candidate: ‘long double std::sqrt(long double)’
    220 |  inline long double sqrt(long double __X) { return __sqrtl(__X); }
        |                     ^~~~
  /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:186:15: note: candidate: ‘float std::sqrt(float)’
    186 |  inline float sqrt(float __X) { return __sqrtf(__X); }
        |               ^~~~
  /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:74:15: note: candidate: ‘double std::sqrt(double)’
     74 | extern double sqrt __P((double));
        |               ^~~~
  /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp:915:67: error: call of overloaded ‘ceil(long unsigned int)’ is ambiguous
    915 |   int Mr = ceil(Nvec * LatencyVectorFma * ThroughputVectorFma / Nr);
        |                                                                   ^
  In file included from /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/math.h:24,
                   from /usr/gcc/9/include/c++/9.1.0/cmath:45,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm-c/DataTypes.h:28,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/Support/DataTypes.h:16,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/ADT/Hashing.h:47,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/include/llvm/ADT/ArrayRef.h:12,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/include/polly/ScheduleOptimizer.h:12,
                   from /var/llvm/llvm-9.0.0-rc4/rc4/llvm.src/tools/polly/lib/Transform/ScheduleOptimizer.cpp:48:
  /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:196:21: note: candidate: ‘long double std::ceil(long double)’
    196 |  inline long double ceil(long double __X) { return __ceill(__X); }
        |                     ^~~~
  /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:160:15: note: candidate: ‘float std::ceil(float)’
    160 |  inline float ceil(float __X) { return __ceilf(__X); }
        |               ^~~~
  /usr/gcc/9/lib/gcc/x86_64-pc-solaris2.11/9.1.0/include-fixed/iso/math_iso.h:76:15: note: candidate: ‘double std::ceil(double)’
     76 | extern double ceil __P((double));
        |               ^~~~

Fixed by adding casts to disambiguate, checked that it now compiles on both 
`amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11` and on `x86_64-pc-linux-gnu`.

Ok for trunk?


Repository:
  rPLO Polly

https://reviews.llvm.org/D67442

Files:
  lib/Transform/ScheduleOptimizer.cpp


Index: lib/Transform/ScheduleOptimizer.cpp
===================================================================
--- lib/Transform/ScheduleOptimizer.cpp
+++ lib/Transform/ScheduleOptimizer.cpp
@@ -910,9 +910,10 @@
   auto Nvec = RegisterBitwidth / ElementSize;
   if (Nvec == 0)
     Nvec = 2;
-  int Nr =
-      ceil(sqrt(Nvec * LatencyVectorFma * ThroughputVectorFma) / Nvec) * Nvec;
-  int Mr = ceil(Nvec * LatencyVectorFma * ThroughputVectorFma / Nr);
+  int Nr = ceil(sqrt((double)(Nvec * LatencyVectorFma * ThroughputVectorFma)) /
+                Nvec) *
+           Nvec;
+  int Mr = ceil((double)(Nvec * LatencyVectorFma * ThroughputVectorFma / Nr));
   return {Mr, Nr};
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67442.219697.patch
Type: text/x-patch
Size: 683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190911/6add09bd/attachment.bin>


More information about the llvm-commits mailing list