The integer division of a numerator n by a divisor d gives a quotient q and a remainder r. Optimizing compilers accelerate software by replacing the division of n by d with the division of c * n (or c * n + c) by m for convenient integers c and m chosen so that they approximate the reciprocal: c/m ~= 1/d. Such techniques are especially advantageous when m is chosen to be a power of two and when d is a constant so that c and m can be precomputed. The literature contains many bounds on the distance between c/m and the divisor d. Some of these bounds are optimally tight, while others are not. We present optimally tight bounds for quotient and remainder computations.
翻译:分子 n 的整数除以 d 表示一个商数 q 和 其余 r 表示一个 q 和 r 。 优化编译器加速软件, 将 n 的除法替换为 d, 以 c * n (或 c * n + c) 和 m 表示, 以方便的整数 c 和 m 表示, 以相近的 : c/ m \ \ 1/ d 。 当 m 被选为 2 和 d 是 常数 从而 C 和 m 可以 预先计算 。 文献含有 c/ m 和 divisor d 之间距离的许多界限 。 其中一些界限最理想地紧紧, 而另一些则不紧 。 我们为商数计算和剩余计算提供了最优的紧凑的界限 。