[llvm] [ADT] Add APIntOps::abds signed absolute difference and rename absdiff -> abdu (PR #84791)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 11 09:45:42 PDT 2024


================
@@ -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);
----------------
jayfoad wrote:

Don't need the parens (but I'm not insisting you remove them if you prefer them).

https://github.com/llvm/llvm-project/pull/84791


More information about the llvm-commits mailing list