[PATCH] D119324: [MLIR][Presburger] Disambiguate call to floor

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 9 03:49:23 PST 2022


ro created this revision.
ro added reviewers: pashu123, bondhugula.
ro added a project: MLIR.
Herald added subscribers: arjunp, sdasgup3, Groverkss, wenzhicui, wrengr, Chia-hungDuan, dcaballe, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, antiagainst, shauheen, rriddle, mehdi_amini, fedor.sergeev, jyknight.
ro requested review of this revision.
Herald added subscribers: stephenneuendorffer, nicolasvasilache.

While testing LLVM 14.0.0 rc1 on Solaris, compilation of `FAIL`ed with

  /var/llvm/llvm-14.0.0-rc1/rc1/llvm-project/mlir/lib/Analysis/Presburger/Utils.cpp: In lambda function:
  /var/llvm/llvm-14.0.0-rc1/rc1/llvm-project/mlir/lib/Analysis/Presburger/Utils.cpp:48:58: error: call of overloaded ‘floor(int64_t)’ is ambiguous
     48 |                  [gcd](int64_t &n) { return floor(n / gcd); });
        |                                                          ^
  ...
  /usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.3.0/include-fixed/iso/math_iso.h:201:21: note: candidate: ‘long double std::floor(long double)’
    201 |  inline long double floor(long double __X) { return __floorl(__X); }
        |                     ^~~~~
  /usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.3.0/include-fixed/iso/math_iso.h:165:15: note: candidate: ‘float std::floor(float)’
    165 |  inline float floor(float __X) { return __floorf(__X); }
        |               ^~~~~
  /usr/gcc/10/lib/gcc/sparcv9-sun-solaris2.11/10.3.0/include-fixed/iso/math_iso.h:78:15: note: candidate: ‘double std::floor(double)’
     78 | extern double floor __P((double));
        |               ^~~~~

The same issue had already occured in the past, cf. D108750 <https://reviews.llvm.org/D108750>, and the solution is the same: cast the `floor` arg to `double`.

Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.

Obviously this should also be backported to the `release/14.x` branch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119324

Files:
  mlir/lib/Analysis/Presburger/Utils.cpp


Index: mlir/lib/Analysis/Presburger/Utils.cpp
===================================================================
--- mlir/lib/Analysis/Presburger/Utils.cpp
+++ mlir/lib/Analysis/Presburger/Utils.cpp
@@ -45,7 +45,7 @@
 
   // Normalize the dividend and the denominator.
   std::transform(dividend.begin(), dividend.end(), dividend.begin(),
-                 [gcd](int64_t &n) { return floor(n / gcd); });
+                 [gcd](int64_t &n) { return floor((double)(n / gcd)); });
   divisor /= gcd;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119324.407111.patch
Type: text/x-patch
Size: 504 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220209/49fcaea5/attachment.bin>


More information about the llvm-commits mailing list