[MLIR][Presburger] SlowMPInt: gcd: assert that operands are non-negative
This commit is contained in:
parent
07022e6cf9
commit
86d73c11cf
|
@ -66,6 +66,7 @@ public:
|
|||
friend SlowMPInt abs(const SlowMPInt &x);
|
||||
friend SlowMPInt ceilDiv(const SlowMPInt &lhs, const SlowMPInt &rhs);
|
||||
friend SlowMPInt floorDiv(const SlowMPInt &lhs, const SlowMPInt &rhs);
|
||||
/// The operands must be non-negative for gcd.
|
||||
friend SlowMPInt gcd(const SlowMPInt &a, const SlowMPInt &b);
|
||||
|
||||
/// Overload to compute a hash_code for a SlowMPInt value.
|
||||
|
|
|
@ -218,8 +218,8 @@ SlowMPInt detail::mod(const SlowMPInt &lhs, const SlowMPInt &rhs) {
|
|||
}
|
||||
|
||||
SlowMPInt detail::gcd(const SlowMPInt &a, const SlowMPInt &b) {
|
||||
return SlowMPInt(
|
||||
llvm::APIntOps::GreatestCommonDivisor(a.val.abs(), b.val.abs()));
|
||||
assert(a >= 0 && b >= 0 && "operands must be non-negative!");
|
||||
return SlowMPInt(llvm::APIntOps::GreatestCommonDivisor(a.val, b.val));
|
||||
}
|
||||
|
||||
/// Returns the least common multiple of 'a' and 'b'.
|
||||
|
|
Loading…
Reference in New Issue