forked from OSchip/llvm-project
Use std::gcd (NFC)
To avoid changing semantics inadvertently, this patch casts arguments to uint64_t before calling std::gcd.
This commit is contained in:
parent
267f21a21b
commit
4a2377afd6
|
@ -659,7 +659,7 @@ bool IntegerRelation::isEmptyByGCDTest() const {
|
|||
for (unsigned i = 0, e = getNumEqualities(); i < e; ++i) {
|
||||
uint64_t gcd = std::abs(atEq(i, 0));
|
||||
for (unsigned j = 1; j < numCols - 1; ++j) {
|
||||
gcd = llvm::GreatestCommonDivisor64(gcd, std::abs(atEq(i, j)));
|
||||
gcd = std::gcd(gcd, (uint64_t)std::abs(atEq(i, j)));
|
||||
}
|
||||
int64_t v = std::abs(atEq(i, numCols - 1));
|
||||
if (gcd > 0 && (v % gcd != 0)) {
|
||||
|
|
|
@ -316,7 +316,7 @@ SmallVector<int64_t, 8> presburger::getDivLowerBound(ArrayRef<int64_t> dividend,
|
|||
int64_t presburger::gcdRange(ArrayRef<int64_t> range) {
|
||||
int64_t gcd = 0;
|
||||
for (int64_t elem : range) {
|
||||
gcd = llvm::GreatestCommonDivisor64(gcd, std::abs(elem));
|
||||
gcd = std::gcd((uint64_t)gcd, (uint64_t)std::abs(elem));
|
||||
if (gcd == 1)
|
||||
return gcd;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "mlir/Support/MathExtras.h"
|
||||
#include "mlir/Support/TypeID.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include <numeric>
|
||||
|
||||
using namespace mlir;
|
||||
using namespace mlir::detail;
|
||||
|
@ -235,9 +236,8 @@ int64_t AffineExpr::getLargestKnownDivisor() const {
|
|||
[[fallthrough]];
|
||||
case AffineExprKind::Mod: {
|
||||
binExpr = cast<AffineBinaryOpExpr>();
|
||||
return llvm::GreatestCommonDivisor64(
|
||||
binExpr.getLHS().getLargestKnownDivisor(),
|
||||
binExpr.getRHS().getLargestKnownDivisor());
|
||||
return std::gcd((uint64_t)binExpr.getLHS().getLargestKnownDivisor(),
|
||||
(uint64_t)binExpr.getRHS().getLargestKnownDivisor());
|
||||
}
|
||||
}
|
||||
llvm_unreachable("Unknown AffineExpr");
|
||||
|
@ -267,9 +267,8 @@ bool AffineExpr::isMultipleOf(int64_t factor) const {
|
|||
case AffineExprKind::CeilDiv:
|
||||
case AffineExprKind::Mod: {
|
||||
binExpr = cast<AffineBinaryOpExpr>();
|
||||
return llvm::GreatestCommonDivisor64(
|
||||
binExpr.getLHS().getLargestKnownDivisor(),
|
||||
binExpr.getRHS().getLargestKnownDivisor()) %
|
||||
return std::gcd((uint64_t)binExpr.getLHS().getLargestKnownDivisor(),
|
||||
(uint64_t)binExpr.getRHS().getLargestKnownDivisor()) %
|
||||
factor ==
|
||||
0;
|
||||
}
|
||||
|
@ -1201,7 +1200,7 @@ void SimpleAffineExprFlattener::visitModExpr(AffineBinaryOpExpr expr) {
|
|||
SmallVector<int64_t, 8> floorDividend(lhs);
|
||||
uint64_t gcd = rhsConst;
|
||||
for (unsigned i = 0, e = lhs.size(); i < e; i++)
|
||||
gcd = llvm::GreatestCommonDivisor64(gcd, std::abs(lhs[i]));
|
||||
gcd = std::gcd(gcd, (uint64_t)std::abs(lhs[i]));
|
||||
// Simplify the numerator and the denominator.
|
||||
if (gcd != 1) {
|
||||
for (unsigned i = 0, e = floorDividend.size(); i < e; i++)
|
||||
|
@ -1313,7 +1312,7 @@ void SimpleAffineExprFlattener::visitDivExpr(AffineBinaryOpExpr expr,
|
|||
// common divisors of the numerator and denominator.
|
||||
uint64_t gcd = std::abs(rhsConst);
|
||||
for (unsigned i = 0, e = lhs.size(); i < e; i++)
|
||||
gcd = llvm::GreatestCommonDivisor64(gcd, std::abs(lhs[i]));
|
||||
gcd = std::gcd(gcd, (uint64_t)std::abs(lhs[i]));
|
||||
// Simplify the numerator and the denominator.
|
||||
if (gcd != 1) {
|
||||
for (unsigned i = 0, e = lhs.size(); i < e; i++)
|
||||
|
|
|
@ -67,6 +67,7 @@
|
|||
#include "isl/options.h"
|
||||
#include "isl/set.h"
|
||||
#include <cassert>
|
||||
#include <numeric>
|
||||
|
||||
using namespace llvm;
|
||||
using namespace polly;
|
||||
|
@ -292,7 +293,7 @@ void ScopArrayInfo::updateElementType(Type *NewElementType) {
|
|||
if (NewElementSize % OldElementSize == 0 && NewElementSize < OldElementSize) {
|
||||
ElementType = NewElementType;
|
||||
} else {
|
||||
auto GCD = GreatestCommonDivisor64(NewElementSize, OldElementSize);
|
||||
auto GCD = std::gcd((uint64_t)NewElementSize, (uint64_t)OldElementSize);
|
||||
ElementType = IntegerType::get(ElementType->getContext(), GCD);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue