[llvm] [APInt] Add APIntOps::absdiff to compute the absolute difference of 2 unsigned values (PR #82255)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 19 07:29:57 PST 2024
================
@@ -2187,6 +2187,11 @@ inline const APInt &umax(const APInt &A, const APInt &B) {
return A.ugt(B) ? A : B;
}
+/// Determine the absolute difference of two APInts considered to be unsigned.
+inline const APInt absdiff(const APInt &A, const APInt &B) {
+ return umax(A, B) - umin(A, B);
----------------
RKSimon wrote:
Sure no problem, is this purely for ease of understanding or anything else?
https://github.com/llvm/llvm-project/pull/82255
More information about the llvm-commits
mailing list