diff options
Diffstat (limited to 'llvm/include/llvm/ADT/APInt.h')
-rw-r--r-- | llvm/include/llvm/ADT/APInt.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h index 1fc3c7b2236a..bea3e28adf30 100644 --- a/llvm/include/llvm/ADT/APInt.h +++ b/llvm/include/llvm/ADT/APInt.h @@ -2188,8 +2188,13 @@ 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 signed. +inline const APInt abds(const APInt &A, const APInt &B) { + return A.sge(B) ? (A - B) : (B - A); +} + /// Determine the absolute difference of two APInts considered to be unsigned. -inline const APInt absdiff(const APInt &A, const APInt &B) { +inline const APInt abdu(const APInt &A, const APInt &B) { return A.uge(B) ? (A - B) : (B - A); } |