diff options
Diffstat (limited to 'gcc/double-int.c')
-rw-r--r-- | gcc/double-int.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/gcc/double-int.c b/gcc/double-int.c index ff31c5c57e7..ae63ead903f 100644 --- a/gcc/double-int.c +++ b/gcc/double-int.c @@ -865,6 +865,26 @@ double_int_umod (double_int a, double_int b, unsigned code) return double_int_mod (a, b, true, code); } +/* Return TRUE iff PRODUCT is an integral multiple of FACTOR, and return + the multiple in *MULTIPLE. Otherwise return FALSE and leave *MULTIPLE + unchanged. */ + +bool +double_int_multiple_of (double_int product, double_int factor, + bool unsigned_p, double_int *multiple) +{ + double_int remainder; + double_int quotient = double_int_divmod (product, factor, unsigned_p, + TRUNC_DIV_EXPR, &remainder); + if (double_int_zero_p (remainder)) + { + *multiple = quotient; + return true; + } + + return false; +} + /* Set BITPOS bit in A. */ double_int double_int_setbit (double_int a, unsigned bitpos) |